diff --git a/.Rbuildignore b/.Rbuildignore index bb697b892b8..7fd9942f350 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,5 +1,3 @@ -src/vendor/cigraph - ^tags$ ^.github$ ^cigraph$ @@ -44,5 +42,9 @@ src/vendor/cigraph ^CITATION\.cff$ ^cran$ ^R/cran\.R$ +^src/build$ +^src/install$ +^src/vendor/cigraph/\..*$ +^rconfigure\.py$ ^\.ccache$ ^\.aviator/config\.yml$ diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index e51977cf4df..d1c27a49167 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -10,6 +10,10 @@ on: - main - fix/* +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.sha }}-${{ github.base_ref || '' }} + cancel-in-progress: true + name: R-CMD-check jobs: @@ -35,6 +39,7 @@ jobs: - name: apt update run: | sudo apt-get update + sudo apt-get install -y libarpack2-dev shell: bash - name: Cache Python virtualenv @@ -135,6 +140,19 @@ jobs: save: false restore: false + - name: apt update + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libarpack2-dev + shell: bash + + - name: apt update + if: runner.os == 'macOS' + run: | + brew install glpk + shell: bash + - name: Setup R uses: r-lib/actions/setup-r@v2 with: @@ -154,7 +172,7 @@ jobs: - name: Check R package uses: r-lib/actions/check-r-package@v2 with: - error-on: '"note"' + error-on: '"error"' coverage: runs-on: ubuntu-20.04 @@ -173,6 +191,12 @@ jobs: with: fetch-depth: 0 + - name: apt update + run: | + sudo apt-get update + sudo apt-get install -y libarpack2-dev + shell: bash + - name: Setup R uses: r-lib/actions/setup-r@v2 @@ -188,7 +212,6 @@ jobs: - name: Run coverage run: | line_exclusions <- fs::dir_ls(c("src/vendor"), type = "file", recurse = TRUE) - cov <- covr::package_coverage( type = c("tests", "examples"), line_exclusions = as.list(names(line_exclusions)), @@ -212,6 +235,7 @@ jobs: - name: apt update run: | sudo apt-get update + sudo apt-get install -y libarpack2-dev shell: bash - name: run sanitizer @@ -221,6 +245,7 @@ jobs: options: --rm --platform linux/amd64 -v ${{ github.workspace }}:/rigraph run: | set -e + printenv cd rigraph RDcsan CMD INSTALL . --no-byte-compile TESTTHAT_PARALLEL=false CI=true RDcsan -q -e 'testthat::test_local(reporter = c("location", "summary"), load_package = "installed")' diff --git a/.gitignore b/.gitignore index 2241cb39784..fd025915a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ igraph.Rcheck/ .vscode/ .Rproj.user /configure~ -/build/ +/src/build/ +/src/install/ inst/doc cran diff --git a/.gitmodules b/.gitmodules index 784bb97c1d9..e69de29bb2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +0,0 @@ -[submodule "cigraph"] - path = cigraph - url = https://github.com/igraph/igraph.git - branch = cran diff --git a/Makefile-cigraph b/Makefile-cigraph index c53c95da7f9..b3f7b998cb9 100644 --- a/Makefile-cigraph +++ b/Makefile-cigraph @@ -10,9 +10,7 @@ all: pre_build ######################################################## # Main package -top_srcdir=cigraph -# FIXME: with the switch to igraph 0.10, change to: -# vendored_srcdir=src/vendor/cigraph +top_srcdir=src/vendor/cigraph vendored_srcdir=$(top_srcdir) VERSION=$(shell tools/getversion.sh) @@ -22,54 +20,23 @@ VERSION=$(shell tools/getversion.sh) version_number: force @echo '$(VERSION)' | cmp -s - $@ || echo '$(VERSION)' > $@ -# Source files from the C library -CORESRC := $(shell cd $(top_srcdir) ; git ls-files --full-name src | \ - grep -v '\.txt$$' | grep -v "COPYING$$" | grep -v "README" | \ - grep -v "src/config.h.in" ) - -# Vendored dependencies of the C library. We don't need BLAS / LAPACK -# because they are included in R. We don't need F2C either because we -# will use the original Fortran sources for ARPACK. We also rely on an -# external GLPK instead of the one vendored in igraph because the -# vendored GLPK does not fit well in the build process of the R interface. -VENDORSRC := $(shell cd $(top_srcdir) ; git ls-files --full-name vendor | \ - grep -v "^vendor/lapack/" | grep -v "^vendor/f2c" | \ - grep -v "^vendor/glpk/" | \ - grep -v '\.txt$$' | grep -v "COPYING$$" | grep -v "README" ) - -# Include files from the C library -CINC := $(shell cd $(top_srcdir) ; git ls-files --full-name include) -CINC := $(patsubst include/%, src/include/%, $(CINC)) - -# Transform CORESRC and VENDORSRC to their target folders in src/ -CORESRC := $(patsubst src/%, src/core/%, $(CORESRC)) -VENDORSRC := $(patsubst vendor/%, src/vendor/%, $(VENDORSRC)) - -# Rules that copy the sources from cigraph/ to src/ -$(CORESRC): src/core/%: $(top_srcdir)/src/% - mkdir -p $(@D) && cp $< $@ -$(VENDORSRC): src/vendor/%: $(top_srcdir)/vendor/% - mkdir -p $(@D) && cp $< $@ -$(CINC): src/include/%: $(top_srcdir)/include/% - mkdir -p $(@D) && cp $< $@ - # Files generated by flex/bison PARSER := $(shell cd $(top_srcdir) ; git ls-files --full-name src | \ grep -E '\.(l|y)$$') -PARSER1 := $(patsubst src/%.l, src/core/%.c, $(PARSER)) -PARSER2 := $(patsubst src/%.y, src/core/%.c, $(PARSER1)) +PARSER1 := $(patsubst src/%.l, src/%.c, $(PARSER)) +PARSER2 := $(patsubst src/%.y, src/%.c, $(PARSER1)) YACC=bison -b yy -d LEX=flex %.c: %.y $(YACC) $< - mv -f yy.tab.c $@ - mv -f yy.tab.h $(@:.c=.h) + mv -f yy.tab.c src/vendor/io/$(notdir $@) + mv -f yy.tab.h src/vendor/io/parsers/$(basename $(notdir $@)).h %.c: %.l - $(LEX) -o $@ --header-file=$(@:.c=.h) $< + $(LEX) -o src/vendor/io/$(notdir $@) --header-file=src/vendor/io/parsers/$(basename $(notdir $@)).h $< # Create Python virtualenv for Stimulus @@ -83,15 +50,12 @@ $(PYVENV)/stamp: tools/build-requirements.txt # Apply possible patches patches: $(CORESRC) $(VENDORSRC) $(CINC) $(PARSER2) - if [ -d "patches" ]; then \ - find patches -type f -name '*.patch' -print0 | sort -z | xargs -t -0 -n 1 tools/apply-patch.sh; \ - fi -rm -f src/*.orig tools/fix-lexers.sh # C files generated by C configure -CGEN = src/include/igraph_export.h src/include/igraph_threading.h src/include/igraph_version.h +CGEN = src/include/igraph_export.h src/include/igraph_threading.h src/include/igraph_version.h src/sources.mk src/include/igraph_export.h: tools/stimulus/igraph_export.h mkdir -p src/include @@ -105,6 +69,11 @@ src/include/igraph_version.h: $(top_srcdir)/include/igraph_version.h.in mkdir -p src/include cp $< $@ +# Create sources.mk + +src/sources.mk: + $(PYTHON) rconfigure.py + # R source and doc files RSRC := $(shell git ls-files R doc inst demo NEWS cleanup.win configure.win) @@ -201,8 +170,9 @@ src/Makevars.win src/Makevars.ucrt src/Makevars.in: src/%: tools/stimulus/% \ # Can't insert newlines, not all make variants accept them cat object_files >> $@ -pre_build: venv patches $(CSRC) $(CINC2) $(PARSER2) $(RSRC) $(RGEN) \ - $(CGEN) $(RAY2) $(ARPACK2) $(UUID2) +pre_build: venv patches $(RSRC) \ + $(CGEN) $(RAY2) $(ARPACK2) $(UUID2) \ + $(PARSER2) clean: rm -rf src/core src/vendor src/include src/Makevars.in src/Makevars.ucrt src/Makevars.win src/config.h.in src/rinterface.c R/aaa-auto.R diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 51e9fff099e..d1c530fafb8 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -1,5 +1,28 @@ # styler: off +copy_impl <- function(from) { + # Argument checks + ensure_igraph(from) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_copy, from) + + res +} + +delete_vertices_idx_impl <- function(graph, vertices) { + # Argument checks + ensure_igraph(graph) + vertices <- as_igraph_vs(graph, vertices) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_delete_vertices_idx, graph, vertices-1) + + res +} + vcount_impl <- function(graph) { # Argument checks ensure_igraph(graph) @@ -12,11 +35,155 @@ vcount_impl <- function(graph) { res } +empty_attrs_impl <- function(n, directed, attr) { + # Argument checks + n <- as.numeric(n) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_empty_attrs, n, directed, attr) + + res +} + +get_all_eids_between_impl <- function(graph, from, to, directed=TRUE) { + # Argument checks + ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as_igraph_vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") + } + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_all_eids_between, graph, from-1, to-1, directed) + if (igraph_opt("return.vs.es")) { + res <- create_es(graph, res) + } + res +} + +sparse_adjacency_impl <- function(adjmatrix, mode=DIRECTED, loops=ONCE) { + # Argument checks + requireNamespace("Matrix", quietly = TRUE); 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 + requireNamespace("Matrix", quietly = TRUE); 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.numeric(n) + center <- as.numeric(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=NULL) { + # Argument checks + dimvector <- as.numeric(dimvector) + nei <- as.numeric(nei) + directed <- as.logical(directed) + mutual <- as.logical(mutual) + if (!is.null(periodic)) 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.numeric(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.numeric(n) + children <- as.numeric(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.numeric(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.numeric(h) + k <- as.numeric(k) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_regular_tree, h, k, type) + + res +} + +graph_power_impl <- function(graph, order, directed=FALSE) { + # Argument checks + ensure_igraph(graph) + order <- as.numeric(order) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_graph_power, graph, order, directed) + + res +} + lcf_vector_impl <- function(n, shifts, repeats=1) { # Argument checks - n <- as.integer(n) + n <- as.numeric(n) shifts <- as.numeric(shifts) - repeats <- as.integer(repeats) + repeats <- as.numeric(repeats) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -31,8 +198,8 @@ lcf_vector_impl <- function(n, shifts, repeats=1) { adjlist_impl <- function(adjlist, mode=c("out", "in", "all", "total"), duplicate=TRUE) { # Argument checks - adjlist <- lapply(adjlist, function(x) as.integer(x)-1L) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + adjlist <- lapply(adjlist, function(x) as.double(x)-1L) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) duplicate <- as.logical(duplicate) on.exit( .Call(R_igraph_finalizer) ) @@ -42,6 +209,19 @@ 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.numeric(n) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_full_multipartite, n, directed, mode) + + 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) @@ -65,12 +245,62 @@ 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.numeric(n) + shifts <- as.numeric(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.numeric(n) + k <- as.numeric(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.numeric(n) + r <- as.numeric(r) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_turan, n, r) + + res +} + +weighted_sparsemat_impl <- function(A, directed, attr, loops=FALSE) { + # Argument checks + requireNamespace("Matrix", quietly = TRUE); 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 +} + forest_fire_game_impl <- function(nodes, fw.prob, bw.factor=1, ambs=1, directed=TRUE) { # Argument checks - nodes <- as.integer(nodes) + nodes <- as.numeric(nodes) fw.prob <- as.numeric(fw.prob) bw.factor <- as.numeric(bw.factor) - ambs <- as.integer(ambs) + ambs <- as.numeric(ambs) directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) @@ -89,10 +319,10 @@ forest_fire_game_impl <- function(nodes, fw.prob, bw.factor=1, ambs=1, directed= simple_interconnected_islands_game_impl <- function(islands.n, islands.size, islands.pin, n.inter) { # Argument checks - islands.n <- as.integer(islands.n) - islands.size <- as.integer(islands.size) + islands.n <- as.numeric(islands.n) + islands.size <- as.numeric(islands.size) islands.pin <- as.numeric(islands.pin) - n.inter <- as.integer(n.inter) + n.inter <- as.numeric(n.inter) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -111,7 +341,7 @@ simple_interconnected_islands_game_impl <- function(islands.n, islands.size, isl static_fitness_game_impl <- function(no.of.edges, fitness.out, fitness.in=NULL, loops=FALSE, multiple=FALSE) { # Argument checks - no.of.edges <- as.integer(no.of.edges) + no.of.edges <- as.numeric(no.of.edges) fitness.out <- as.numeric(fitness.out) if (!is.null(fitness.in)) fitness.in <- as.numeric(fitness.in) loops <- as.logical(loops) @@ -132,8 +362,8 @@ static_fitness_game_impl <- function(no.of.edges, fitness.out, fitness.in=NULL, static_power_law_game_impl <- function(no.of.nodes, no.of.edges, exponent.out, exponent.in=-1, loops=FALSE, multiple=FALSE, finite.size.correction=TRUE) { # Argument checks - no.of.nodes <- as.integer(no.of.nodes) - no.of.edges <- as.integer(no.of.edges) + no.of.nodes <- as.numeric(no.of.nodes) + no.of.edges <- as.numeric(no.of.edges) exponent.out <- as.numeric(exponent.out) exponent.in <- as.numeric(exponent.in) loops <- as.logical(loops) @@ -158,8 +388,8 @@ static_power_law_game_impl <- function(no.of.nodes, no.of.edges, exponent.out, e k_regular_game_impl <- function(no.of.nodes, k, directed=FALSE, multiple=FALSE) { # Argument checks - no.of.nodes <- as.integer(no.of.nodes) - k <- as.integer(k) + no.of.nodes <- as.numeric(no.of.nodes) + k <- as.numeric(k) directed <- as.logical(directed) multiple <- as.logical(multiple) @@ -177,9 +407,9 @@ k_regular_game_impl <- function(no.of.nodes, k, directed=FALSE, multiple=FALSE) sbm_game_impl <- function(n, pref.matrix, block.sizes, directed=FALSE, loops=FALSE) { # Argument checks - n <- as.integer(n) + n <- as.numeric(n) pref.matrix <- as.matrix(structure(as.double(pref.matrix), dim=dim(pref.matrix))) - block.sizes <- as.integer(block.sizes) + block.sizes <- as.numeric(block.sizes) directed <- as.logical(directed) loops <- as.logical(loops) @@ -197,8 +427,8 @@ sbm_game_impl <- function(n, pref.matrix, block.sizes, directed=FALSE, loops=FAL hsbm_game_impl <- function(n, m, rho, C, p) { # Argument checks - n <- as.integer(n) - m <- as.integer(m) + n <- as.numeric(n) + m <- as.numeric(m) rho <- as.numeric(rho) C <- as.matrix(structure(as.double(C), dim=dim(C))) p <- as.numeric(p) @@ -220,11 +450,8 @@ hsbm_game_impl <- function(n, m, rho, C, p) { hsbm_list_game_impl <- function(n, mlist, rholist, Clist, p) { # Argument checks - n <- as.integer(n) - mlist <- as.integer(mlist) - if (!all(sapply(Clist, is.matrix))) { - stop("Clist is not a list of matrices") - } + n <- as.numeric(n) + mlist <- as.numeric(mlist) p <- as.numeric(p) on.exit( .Call(R_igraph_finalizer) ) @@ -244,7 +471,7 @@ correlated_game_impl <- function(old.graph, corr, p=edge_density(old.graph), per ensure_igraph(old.graph) corr <- as.numeric(corr) p <- as.numeric(p) - if (!is.null(permutation)) permutation <- as.numeric(permutation)-1 + if (!is.null(permutation)) permutation <- as.numeric(permutation)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -261,11 +488,11 @@ correlated_game_impl <- function(old.graph, corr, p=edge_density(old.graph), per correlated_pair_game_impl <- function(n, corr, p, directed=FALSE, permutation=NULL) { # Argument checks - n <- as.integer(n) + n <- as.numeric(n) corr <- as.numeric(corr) p <- as.numeric(p) directed <- as.logical(directed) - if (!is.null(permutation)) permutation <- as.numeric(permutation)-1 + if (!is.null(permutation)) permutation <- as.numeric(permutation)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -288,8 +515,8 @@ dot_product_game_impl <- function(vecs, directed=FALSE) { sample_sphere_surface_impl <- function(dim, n=1, radius=1, positive=TRUE) { # Argument checks - dim <- as.integer(dim) - n <- as.integer(n) + dim <- as.numeric(dim) + n <- as.numeric(n) radius <- as.numeric(radius) positive <- as.logical(positive) @@ -302,8 +529,8 @@ sample_sphere_surface_impl <- function(dim, n=1, radius=1, positive=TRUE) { sample_sphere_volume_impl <- function(dim, n=1, radius=1, positive=TRUE) { # Argument checks - dim <- as.integer(dim) - n <- as.integer(n) + dim <- as.numeric(dim) + n <- as.numeric(n) radius <- as.numeric(radius) positive <- as.logical(positive) @@ -316,7 +543,7 @@ sample_sphere_volume_impl <- function(dim, n=1, radius=1, positive=TRUE) { sample_dirichlet_impl <- function(n, alpha) { # Argument checks - n <- as.integer(n) + n <- as.numeric(n) alpha <- as.numeric(alpha) on.exit( .Call(R_igraph_finalizer) ) @@ -326,39 +553,71 @@ 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=V(graph), to=V(graph), mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - 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 + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_distances, graph, from-1, to-1, mode) + + res +} + +distances_cutoff_impl <- function(graph, from=V(graph), to=V(graph), mode=c("out", "in", "all", "total"), cutoff=-1) { + # Argument checks + ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + cutoff <- as.numeric(cutoff) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_distances_cutoff, graph, from-1, to-1, mode, cutoff) + + res +} + +get_shortest_path_impl <- function(graph, from, to, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") } - if (!is.null(weights) && any(!is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL + to <- as_igraph_vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") } - normalized <- as.logical(normalized) - cutoff <- as.numeric(cutoff) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_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_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_es(graph, res$edges) } res } -personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V(graph), directed=TRUE, damping=0.85, personalized=NULL, weights=NULL, options=NULL) { +get_shortest_path_bellman_ford_impl <- function(graph, from, to, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) - vids <- as_igraph_vs(graph, vids) - directed <- as.logical(directed) - damping <- as.numeric(damping) - if (!is.null(personalized)) personalized <- as.numeric(personalized) + 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 } @@ -367,40 +626,58 @@ personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V } 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"=1L, "in"=2L, "all"=3L, "total"=3L) 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_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_es(graph, res$edges) } res } -reverse_edges_impl <- function(graph, eids=E(graph)) { +get_shortest_path_dijkstra_impl <- function(graph, from, to, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - 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") + } + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_reverse_edges, graph, eids-1) - + 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_es(graph, res$edges) + } res } -average_path_length_dijkstra_impl <- function(graph, weights=NULL, directed=TRUE, unconnected=TRUE, details=FALSE) { +distances_dijkstra_impl <- function(graph, from=V(graph), to=V(graph), weights, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -409,47 +686,65 @@ 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"=1L, "in"=2L, "all"=3L, "total"=3L) 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_distances_dijkstra, graph, from-1, to-1, weights, mode) + res } -path_length_hist_impl <- function(graph, directed=TRUE) { +distances_dijkstra_cutoff_impl <- function(graph, from=V(graph), to=V(graph), weights, mode=c("out", "in", "all", "total"), cutoff=-1) { # Argument checks ensure_igraph(graph) - directed <- as.logical(directed) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + cutoff <- as.numeric(cutoff) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_path_length_hist, graph, directed) + res <- .Call(R_igraph_distances_dijkstra_cutoff, graph, from-1, to-1, weights, mode, cutoff) res } -simplify_impl <- function(graph, remove.multiple=TRUE, remove.loops=TRUE, edge.attr.comb=igraph_opt("edge.attr.comb")) { +distances_bellman_ford_impl <- function(graph, from=V(graph), to=V(graph), weights, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - remove.multiple <- as.logical(remove.multiple) - remove.loops <- as.logical(remove.loops) - edge.attr.comb <- igraph.i.attribute.combination(edge.attr.comb) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_simplify, graph, remove.multiple, remove.loops, edge.attr.comb) + res <- .Call(R_igraph_distances_bellman_ford, graph, from-1, to-1, weights, mode) res } -feedback_arc_set_impl <- function(graph, weights=NULL, algo=c("approx_eades", "exact_ip")) { +distances_johnson_impl <- function(graph, from=V(graph), to=V(graph), weights) { # Argument checks ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -458,102 +753,214 @@ 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) 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 <- .Call(R_igraph_distances_johnson, graph, from-1, to-1, weights) + res } -is_loop_impl <- function(graph, eids=E(graph)) { +distances_floyd_warshall_impl <- function(graph, from=V(graph), to=V(graph), weights=NULL, mode=c("out", "in", "all", "total"), method) { # Argument checks ensure_igraph(graph) - eids <- as_igraph_es(graph, eids) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_loop, graph, eids-1) + res <- .Call(R_igraph_distances_floyd_warshall, graph, from-1, to-1, weights, mode, method) res } -is_dag_impl <- function(graph) { +voronoi_impl <- function(graph, generators, weights=NULL, mode=c("out", "in", "all", "total"), tiebreaker=RANDOM) { # Argument checks ensure_igraph(graph) + 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"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_dag, graph) + res <- .Call(R_igraph_voronoi, graph, generators-1, weights, mode, tiebreaker) res } -is_simple_impl <- function(graph) { +get_k_shortest_paths_impl <- function(graph, weights=NULL, k, from, to, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + k <- as.numeric(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"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_simple, graph) - + res <- .Call(R_igraph_get_k_shortest_paths, graph, weights, k, from-1, to-1, mode) + if (igraph_opt("return.vs.es")) { + verts <- V(graph) + for (i_ in seq_along(res$vertex.paths)) { + res$vertex.paths[[i_]] <- unsafe_create_vs(graph, res$vertex.paths[[i_]], verts = verts) + } + } + if (igraph_opt("return.vs.es")) { + es <- E(graph) + for (i_ in seq_along(res$edge.paths)) { + res$edge.paths[[i_]] <- unsafe_create_es(graph, res$edge.paths[[i_]], es = es) + } + } res } -is_multiple_impl <- function(graph, eids=E(graph)) { +get_widest_path_impl <- function(graph, from, to, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - 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") + } + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_multiple, graph, eids-1) - + 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_es(graph, res$edges) + } res } -has_loop_impl <- function(graph) { +get_widest_paths_impl <- function(graph, from, to=V(graph), weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_has_loop, graph) - + res <- .Call(R_igraph_get_widest_paths, graph, from-1, to-1, weights, mode) + if (igraph_opt("return.vs.es")) { + verts <- V(graph) + for (i_ in seq_along(res$vertices)) { + res$vertices[[i_]] <- unsafe_create_vs(graph, res$vertices[[i_]], verts = verts) + } + } + if (igraph_opt("return.vs.es")) { + es <- E(graph) + for (i_ in seq_along(res$edges)) { + res$edges[[i_]] <- unsafe_create_es(graph, res$edges[[i_]], es = es) + } + } res } -has_multiple_impl <- function(graph) { +widest_path_widths_dijkstra_impl <- function(graph, from=V(graph), to=V(graph), weights, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_has_multiple, graph) + res <- .Call(R_igraph_widest_path_widths_dijkstra, graph, from-1, to-1, weights, mode) res } -count_multiple_impl <- function(graph, eids=E(graph)) { +widest_path_widths_floyd_warshall_impl <- function(graph, from=V(graph), to=V(graph), weights, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - eids <- as_igraph_es(graph, eids) + from <- as_igraph_vs(graph, from) + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_multiple, graph, eids-1) + res <- .Call(R_igraph_widest_path_widths_floyd_warshall, graph, from-1, to-1, weights, mode) res } -eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weights=NULL, options=arpack_defaults()) { +spanner_impl <- function(graph, stretch, weights) { # Argument checks ensure_igraph(graph) - directed <- as.logical(directed) - scale <- as.logical(scale) + stretch <- as.numeric(stretch) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -562,21 +969,23 @@ eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weigh } else { weights <- NULL } - options <- modify_list(arpack_defaults(), options) 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 <- .Call(R_igraph_spanner, graph, stretch, weights) + if (igraph_opt("return.vs.es")) { + res <- create_es(, res) } res } -hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { +betweenness_subset_impl <- function(graph, vids=V(graph), directed=TRUE, sources=V(graph), targets=V(graph), weights=NULL) { # Argument checks ensure_igraph(graph) - scale <- as.logical(scale) + vids <- as_igraph_vs(graph, vids) + directed <- as.logical(directed) + sources <- as_igraph_vs(graph, sources) + targets <- as_igraph_vs(graph, targets) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -585,21 +994,23 @@ hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defau } else { weights <- NULL } - options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_hub_score, graph, scale, weights, options) + res <- .Call(R_igraph_betweenness_subset, graph, vids-1, directed, sources-1, targets-1, weights) if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$vector) <- vertex_attr(graph, "name", V(graph)) + names(res) <- vertex_attr(graph, "name", ) } res } -authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { +edge_betweenness_subset_impl <- function(graph, eids=E(graph), directed=TRUE, sources=V(graph), targets=V(graph), weights=NULL) { # Argument checks ensure_igraph(graph) - scale <- as.logical(scale) + eids <- as_igraph_es(graph, eids) + directed <- as.logical(directed) + sources <- as_igraph_vs(graph, sources) + targets <- as_igraph_vs(graph, targets) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -608,48 +1019,49 @@ authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack } else { weights <- NULL } - options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_authority_score, graph, scale, weights, options) + res <- .Call(R_igraph_edge_betweenness_subset, graph, eids-1, directed, sources-1, targets-1, weights) if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$vector) <- vertex_attr(graph, "name", V(graph)) + names(res) <- vertex_attr(graph, "name", ) } res } -is_mutual_impl <- function(graph, eids=E(graph)) { - # Argument checks - ensure_igraph(graph) - eids <- as_igraph_es(graph, eids) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_is_mutual, graph, eids-1) - - res -} - -maximum_cardinality_search_impl <- function(graph) { +harmonic_centrality_cutoff_impl <- function(graph, vids=V(graph), mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE, cutoff=-1) { # Argument checks ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + normalized <- as.logical(normalized) + cutoff <- as.numeric(cutoff) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_maximum_cardinality_search, graph) - if (igraph_opt("return.vs.es")) { - res$alpham1 <- create_vs(graph, res$alpham1) + 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 } -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) { +personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V(graph), directed=TRUE, damping=0.85, personalized=NULL, weights=NULL, options=NULL) { # Argument checks ensure_igraph(graph) + algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) vids <- as_igraph_vs(graph, vids) - 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) + 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 } @@ -658,22 +1070,33 @@ avg_nearest_neighbor_degree_impl <- function(graph, vids=V(graph), mode=c("all", } 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_avg_nearest_neighbor_degree, graph, vids-1, mode, neighbor.degree.mode, weights) + 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$knn) <- vertex_attr(graph, "name", vids) + names(res$vector) <- vertex_attr(graph, "name", vids) } res } -strength_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=TRUE, weights=NULL) { +personalized_pagerank_vs_impl <- function(graph, algo=c("prpack", "arpack"), vids=V(graph), directed=TRUE, damping=0.85, reset.vids, weights=NULL, options=NULL, details=FALSE) { # Argument checks ensure_igraph(graph) + algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - loops <- as.logical(loops) + directed <- as.logical(directed) + damping <- as.numeric(damping) + reset.vids <- as_igraph_vs(graph, reset.vids) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -682,207 +1105,246 @@ strength_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "tota } 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_strength, graph, vids-1, mode, loops, weights) + res <- .Call(R_igraph_personalized_pagerank_vs, graph, algo, vids-1, directed, damping, reset.vids-1, weights, options) if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) + names(res$vector) <- vertex_attr(graph, "name", vids) + } + if (!details) { + res <- res$vector } res } -centralization_impl <- function(scores, theoretical.max=0, normalized=TRUE) { +subgraph_from_edges_impl <- function(graph, eids, delete.vertices=TRUE) { # Argument checks - scores <- as.numeric(scores) - theoretical.max <- as.numeric(theoretical.max) - normalized <- as.logical(normalized) + ensure_igraph(graph) + eids <- as_igraph_es(graph, eids) + delete.vertices <- as.logical(delete.vertices) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_centralization, scores, theoretical.max, normalized) - + res <- .Call(R_igraph_subgraph_from_edges, graph, eids-1, delete.vertices) res } -centralization_degree_impl <- function(graph, mode=c("all", "out", "in", "total"), loops=TRUE, normalized=TRUE) { +reverse_edges_impl <- function(graph, eids=E(graph)) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - loops <- as.logical(loops) - normalized <- as.logical(normalized) + eids <- as_igraph_es(graph, eids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_centralization_degree, graph, mode, loops, normalized) + res <- .Call(R_igraph_reverse_edges, graph, eids-1) res } -centralization_betweenness_impl <- function(graph, directed=TRUE, normalized=TRUE) { +average_path_length_dijkstra_impl <- function(graph, weights=NULL, directed=TRUE, unconnected=TRUE, details=FALSE) { # Argument checks ensure_igraph(graph) - directed <- as.logical(directed) - normalized <- as.logical(normalized) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_centralization_betweenness, graph, directed, normalized) - + 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 } -centralization_betweenness_tmax_impl <- function(graph=NULL, nodes=0, directed=TRUE) { +path_length_hist_impl <- function(graph, directed=TRUE) { # Argument checks - ensure_igraph(graph, optional = TRUE) - nodes <- as.integer(nodes) + ensure_igraph(graph) directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_centralization_betweenness_tmax, graph, nodes, directed) + res <- .Call(R_igraph_path_length_hist, graph, directed) res } -centralization_closeness_impl <- function(graph, mode=c("out", "in", "all", "total"), normalized=TRUE) { +simplify_impl <- function(graph, remove.multiple=TRUE, remove.loops=TRUE, edge.attr.comb=igraph_opt("edge.attr.comb")) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - normalized <- as.logical(normalized) + 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_centralization_closeness, graph, mode, normalized) + res <- .Call(R_igraph_simplify, graph, remove.multiple, remove.loops, edge.attr.comb) res } -centralization_closeness_tmax_impl <- function(graph=NULL, nodes=0, mode=c("out", "in", "all", "total")) { +ecc_impl <- function(graph, eids=E(graph), k=3, offset=FALSE, normalize=TRUE) { # Argument checks - ensure_igraph(graph, optional = TRUE) - nodes <- as.integer(nodes) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + ensure_igraph(graph) + eids <- as_igraph_es(graph, eids) + k <- as.numeric(k) + offset <- as.logical(offset) + normalize <- as.logical(normalize) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_centralization_closeness_tmax, graph, nodes, mode) + res <- .Call(R_igraph_ecc, graph, eids-1, k, offset, normalize) res } -centralization_eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, options=arpack_defaults(), normalized=TRUE) { +feedback_arc_set_impl <- function(graph, weights=NULL, algo=c("approx_eades", "exact_ip")) { # Argument checks ensure_igraph(graph) - directed <- as.logical(directed) - scale <- as.logical(scale) - options <- modify_list(arpack_defaults(), options) - normalized <- as.logical(normalized) + 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_centralization_eigenvector_centrality, graph, directed, scale, options, normalized) + res <- .Call(R_igraph_feedback_arc_set, graph, weights, algo) + if (igraph_opt("return.vs.es")) { + res <- create_es(graph, res) + } + res +} + +is_loop_impl <- function(graph, eids=E(graph)) { + # Argument checks + ensure_igraph(graph) + eids <- as_igraph_es(graph, eids) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_loop, graph, eids-1) res } -centralization_eigenvector_centrality_tmax_impl <- function(graph=NULL, nodes=0, directed=FALSE, scale=TRUE) { +is_dag_impl <- function(graph) { # Argument checks - ensure_igraph(graph, optional = TRUE) - nodes <- as.integer(nodes) - directed <- as.logical(directed) - scale <- as.logical(scale) + ensure_igraph(graph) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_centralization_eigenvector_centrality_tmax, graph, nodes, directed, scale) + res <- .Call(R_igraph_is_dag, graph) res } -assortativity_nominal_impl <- function(graph, types, directed=TRUE) { +is_acyclic_impl <- function(graph) { # Argument checks ensure_igraph(graph) - types <- as.numeric(types)-1 - directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_assortativity_nominal, graph, types, directed) + res <- .Call(R_igraph_is_acyclic, graph) res } -assortativity_impl <- function(graph, types1, types2=NULL, directed=TRUE) { +is_simple_impl <- function(graph) { # Argument checks ensure_igraph(graph) - types1 <- as.numeric(types1) - if (!is.null(types2)) types2 <- as.numeric(types2) - directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_assortativity, graph, types1, types2, directed) + res <- .Call(R_igraph_is_simple, graph) res } -assortativity_degree_impl <- function(graph, directed=TRUE) { +is_multiple_impl <- function(graph, eids=E(graph)) { # Argument checks ensure_igraph(graph) - directed <- as.logical(directed) + eids <- as_igraph_es(graph, eids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_assortativity_degree, graph, directed) + res <- .Call(R_igraph_is_multiple, graph, eids-1) res } -contract_vertices_impl <- function(graph, mapping, vertex.attr.comb=igraph_opt("vertex.attr.comb")) { +has_loop_impl <- function(graph) { # Argument checks ensure_igraph(graph) - mapping <- as.numeric(mapping)-1 - vertex.attr.comb <- igraph.i.attribute.combination(vertex.attr.comb) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_contract_vertices, graph, mapping, vertex.attr.comb) + res <- .Call(R_igraph_has_loop, graph) res } -eccentricity_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { +has_multiple_impl <- function(graph) { # Argument checks ensure_igraph(graph) - 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_has_multiple, graph) + res } -radius_impl <- function(graph, mode=c("all", "out", "in", "total")) { +count_multiple_impl <- function(graph, eids=E(graph)) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + eids <- as_igraph_es(graph, eids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_radius, graph, mode) + res <- .Call(R_igraph_count_multiple, graph, eids-1) res } -diversity_impl <- function(graph, weights=NULL, vids=V(graph)) { +is_perfect_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_perfect, graph) + + res +} + +eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weights=NULL, options=arpack_defaults) { # Argument checks ensure_igraph(graph) + directed <- as.logical(directed) + scale <- as.logical(scale) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -891,40 +1353,44 @@ diversity_impl <- function(graph, weights=NULL, vids=V(graph)) { } else { weights <- NULL } - vids <- as_igraph_vs(graph, vids) + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_diversity, graph, weights, vids-1) + res <- .Call(R_igraph_eigenvector_centrality, graph, directed, scale, weights, options) if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) + names(res$vector) <- vertex_attr(graph, "name", V(graph)) } res } -random_walk_impl <- function(graph, start, steps, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) { +hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { # Argument checks ensure_igraph(graph) - start <- as_igraph_vs(graph, start) - if (length(start) == 0) { - stop("No vertex was specified") + scale <- as.logical(scale) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - steps <- as.integer(steps) - stuck <- switch(igraph.match.arg(stuck), "error" = 0L, "return" = 1L) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_random_walk, graph, start-1, mode, steps, stuck) - if (igraph_opt("return.vs.es")) { - res <- create_vs(graph, res) + 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 } -random_edge_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) { +authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { # Argument checks ensure_igraph(graph) + scale <- as.logical(scale) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -933,26 +1399,21 @@ random_edge_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out } else { weights <- NULL } - start <- as_igraph_vs(graph, start) - if (length(start) == 0) { - stop("No vertex was specified") - } - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - steps <- as.integer(steps) - stuck <- switch(igraph.match.arg(stuck), "error" = 0L, "return" = 1L) + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # 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 <- .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 } -global_efficiency_impl <- function(graph, weights=NULL, directed=TRUE) { +hub_and_authority_scores_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults) { # Argument checks ensure_igraph(graph) + scale <- as.logical(scale) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -961,19 +1422,64 @@ global_efficiency_impl <- function(graph, weights=NULL, directed=TRUE) { } else { weights <- NULL } - directed <- as.logical(directed) + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_global_efficiency, graph, weights, directed) + res <- .Call(R_igraph_hub_and_authority_scores, graph, scale, weights, options) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$hub.vector) <- vertex_attr(graph, "name", ) + } + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$authority.vector) <- vertex_attr(graph, "name", ) + } + res +} + +is_mutual_impl <- function(graph, eids=E(graph), loops=TRUE) { + # Argument checks + ensure_igraph(graph) + 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, loops) res } -local_efficiency_impl <- function(graph, vids=V(graph), weights=NULL, directed=TRUE, mode=c("all", "out", "in", "total")) { +has_mutual_impl <- function(graph, loops=TRUE) { + # Argument checks + ensure_igraph(graph) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_has_mutual, graph, loops) + + res +} + +maximum_cardinality_search_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_maximum_cardinality_search, graph) + 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) { # Argument checks ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + neighbor.degree.mode <- switch(igraph.match.arg(neighbor.degree.mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -982,19 +1488,17 @@ local_efficiency_impl <- function(graph, vids=V(graph), weights=NULL, directed=T } else { weights <- NULL } - 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_local_efficiency, graph, vids-1, weights, directed, mode) + 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) <- vertex_attr(graph, "name", vids) + names(res$knn) <- vertex_attr(graph, "name", vids) } res } -average_local_efficiency_impl <- function(graph, weights=NULL, directed=TRUE, mode=c("all", "out", "in", "total")) { +degree_correlation_vector_impl <- function(graph, weights=NULL, from.mode=c("out", "in", "all", "total"), to.mode=c("in", "out", "all", "total"), directed.neighbors=TRUE) { # Argument checks ensure_igraph(graph) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -1005,367 +1509,360 @@ average_local_efficiency_impl <- function(graph, weights=NULL, directed=TRUE, mo } else { weights <- NULL } - directed <- as.logical(directed) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + from.mode <- switch(igraph.match.arg(from.mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + to.mode <- switch(igraph.match.arg(to.mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + directed.neighbors <- as.logical(directed.neighbors) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_average_local_efficiency, graph, weights, directed, mode) + res <- .Call(R_igraph_degree_correlation_vector, graph, weights, from.mode, to.mode, directed.neighbors) res } -is_graphical_impl <- function(out.deg, in.deg=NULL, allowed.edge.types=c("simple", "loops", "multi", "all")) { +strength_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=TRUE, weights=NULL) { # Argument checks - out.deg <- as.numeric(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) + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + if (is.null(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_is_graphical, out.deg, in.deg, allowed.edge.types) - + 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 } -bipartite_projection_size_impl <- function(graph, types=NULL) { +centralization_impl <- function(scores, theoretical.max=0, normalized=TRUE) { # Argument checks - ensure_igraph(graph) - types <- handle_vertex_type_arg(types, graph) + scores <- as.numeric(scores) + theoretical.max <- as.numeric(theoretical.max) + normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_bipartite_projection_size, graph, types) + res <- .Call(R_igraph_centralization, scores, theoretical.max, normalized) + res } -is_bipartite_impl <- function(graph) { +centralization_degree_impl <- function(graph, mode=c("all", "out", "in", "total"), loops=TRUE, normalized=TRUE) { # Argument checks ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_bipartite, graph) + res <- .Call(R_igraph_centralization_degree, graph, mode, loops, normalized) res } -is_connected_impl <- function(graph, mode=c("weak", "strong")) { +centralization_betweenness_impl <- function(graph, directed=TRUE, normalized=TRUE) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "weak"=1, "strong"=2) + directed <- as.logical(directed) + normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_connected, graph, mode) + res <- .Call(R_igraph_centralization_betweenness, graph, directed, normalized) res } -articulation_points_impl <- function(graph) { +centralization_betweenness_tmax_impl <- function(graph=NULL, nodes=0, directed=TRUE) { # Argument checks - ensure_igraph(graph) + if (!is.null(graph)) ensure_igraph(graph) + nodes <- as.numeric(nodes) + directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_articulation_points, graph) - if (igraph_opt("return.vs.es")) { - res <- create_vs(graph, res) - } + res <- .Call(R_igraph_centralization_betweenness_tmax, graph, nodes, directed) + res } -biconnected_components_impl <- function(graph) { +centralization_closeness_impl <- function(graph, mode=c("out", "in", "all", "total"), normalized=TRUE) { # Argument checks ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + normalized <- as.logical(normalized) 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) - } + res <- .Call(R_igraph_centralization_closeness, graph, mode, normalized) + res } -bridges_impl <- function(graph) { +centralization_closeness_tmax_impl <- function(graph=NULL, nodes=0, mode=c("out", "in", "all", "total")) { # Argument checks - ensure_igraph(graph) + if (!is.null(graph)) ensure_igraph(graph) + nodes <- as.numeric(nodes) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_bridges, graph) - if (igraph_opt("return.vs.es")) { - res <- create_es(graph, res) - } + res <- .Call(R_igraph_centralization_closeness_tmax, graph, nodes, mode) + res } -cliques_impl <- function(graph, min=0, max=0) { +centralization_eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, options=arpack_defaults(), normalized=TRUE) { # Argument checks ensure_igraph(graph) - min <- as.integer(min) - max <- as.integer(max) + directed <- as.logical(directed) + scale <- as.logical(scale) + options <- modify_list(arpack_defaults(), options) + normalized <- as.logical(normalized) 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 <- .Call(R_igraph_centralization_eigenvector_centrality, graph, directed, scale, options, normalized) + res } -clique_size_hist_impl <- function(graph, min.size=0, max.size=0) { +centralization_eigenvector_centrality_tmax_impl <- function(graph=NULL, nodes=0, directed=FALSE, scale=TRUE) { # Argument checks - ensure_igraph(graph) - min.size <- as.integer(min.size) - max.size <- as.integer(max.size) + if (!is.null(graph)) ensure_igraph(graph) + nodes <- as.numeric(nodes) + directed <- as.logical(directed) + scale <- as.logical(scale) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_clique_size_hist, graph, min.size, max.size) + res <- .Call(R_igraph_centralization_eigenvector_centrality_tmax, graph, nodes, directed, scale) res } -largest_cliques_impl <- function(graph) { +assortativity_nominal_impl <- function(graph, types, directed=TRUE, normalized=TRUE) { # Argument checks ensure_igraph(graph) + types <- as.numeric(types)-1L + directed <- as.logical(directed) + normalized <- as.logical(normalized) 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 <- .Call(R_igraph_assortativity_nominal, graph, types, directed, normalized) + res } -maximal_cliques_hist_impl <- function(graph, min.size=0, max.size=0) { +assortativity_impl <- function(graph, values, values.in=NULL, directed=TRUE, normalized=TRUE) { # Argument checks ensure_igraph(graph) - min.size <- as.integer(min.size) - max.size <- as.integer(max.size) + values <- as.numeric(values) + if (!is.null(values.in)) 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_maximal_cliques_hist, graph, min.size, max.size) + res <- .Call(R_igraph_assortativity, graph, values, values.in, directed, normalized) res } -clique_number_impl <- function(graph) { +assortativity_degree_impl <- function(graph, directed=TRUE) { # Argument checks ensure_igraph(graph) + directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_clique_number, graph) + res <- .Call(R_igraph_assortativity_degree, graph, directed) res } -weighted_cliques_impl <- function(graph, vertex.weights=NULL, min.weight=0, max.weight=0, maximal=FALSE) { +joint_degree_matrix_impl <- function(graph, weights=NULL, max.out.degree=-1, max.in.degree=-1) { # Argument checks ensure_igraph(graph) - if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { - vertex.weights <- V(graph)$weight + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { - vertex.weights <- as.numeric(vertex.weights) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) } else { - vertex.weights <- NULL + weights <- NULL } - min.weight <- as.numeric(min.weight) - max.weight <- as.numeric(max.weight) - maximal <- as.logical(maximal) + max.out.degree <- as.numeric(max.out.degree) + max.in.degree <- as.numeric(max.in.degree) 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 <- .Call(R_igraph_joint_degree_matrix, graph, weights, max.out.degree, max.in.degree) + res } -largest_weighted_cliques_impl <- function(graph, vertex.weights=NULL) { +joint_degree_distribution_impl <- function(graph, weights=NULL, from.mode=c("out", "in", "all", "total"), to.mode=c("in", "out", "all", "total"), directed.neighbors=TRUE, normalized=TRUE, max.from.degree=-1, max.to.degree=-1) { # Argument checks ensure_igraph(graph) - if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { - vertex.weights <- V(graph)$weight + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { - vertex.weights <- as.numeric(vertex.weights) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) } else { - vertex.weights <- NULL + weights <- NULL } + from.mode <- switch(igraph.match.arg(from.mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + to.mode <- switch(igraph.match.arg(to.mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + directed.neighbors <- as.logical(directed.neighbors) + normalized <- as.logical(normalized) + max.from.degree <- as.numeric(max.from.degree) + max.to.degree <- as.numeric(max.to.degree) 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 <- .Call(R_igraph_joint_degree_distribution, graph, weights, from.mode, to.mode, directed.neighbors, normalized, max.from.degree, max.to.degree) + res } -weighted_clique_number_impl <- function(graph, vertex.weights=NULL) { +joint_type_distribution_impl <- function(graph, weights=NULL, from.types, to.types=NULL, directed=TRUE, normalized=TRUE) { # Argument checks ensure_igraph(graph) - if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { - vertex.weights <- V(graph)$weight + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { - vertex.weights <- as.numeric(vertex.weights) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) } else { - vertex.weights <- NULL + weights <- NULL } + from.types <- as.numeric(from.types)-1L + to.types <- as.numeric(to.types)-1L + directed <- as.logical(directed) + normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_weighted_clique_number, graph, vertex.weights) + res <- .Call(R_igraph_joint_type_distribution, graph, weights, from.types, to.types, directed, normalized) res } -similarity_jaccard_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +contract_vertices_impl <- function(graph, mapping, vertex.attr.comb=igraph_opt("vertex.attr.comb")) { # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - loops <- as.logical(loops) + mapping <- as.numeric(mapping)-1L + vertex.attr.comb <- igraph.i.attribute.combination(vertex.attr.comb) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_jaccard, graph, vids-1, mode, loops) + res <- .Call(R_igraph_contract_vertices, graph, mapping, vertex.attr.comb) res } -similarity_dice_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +eccentricity_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - loops <- as.logical(loops) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_dice, graph, vids-1, mode, loops) - + 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 } -similarity_inverse_log_weighted_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { +eccentricity_dijkstra_impl <- function(graph, weights=NULL, vids=V(graph), mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=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-1, mode) - - res -} - -hrg_game_impl <- function(hrg) { - # Argument checks - if (is.null(hrg)) { - hrg <- list(left=c(), right=c(), prob=c(), edges=c(), vertices=c()) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - hrg <- lapply(hrg[c("left","right","prob","edges","vertices")], as.numeric) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_hrg_game, hrg) - - if (igraph_opt("add.params")) { - res$name <- 'Hierarchical random graph model' + res <- .Call(R_igraph_eccentricity_dijkstra, graph, weights, vids-1, mode) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res) <- vertex_attr(graph, "name", vids) } - res } -hrg_dendrogram_impl <- function(hrg) { +graph_center_impl <- function(graph, mode=c("all", "out", "in", "total")) { # 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) + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_hrg_dendrogram, hrg) - + res <- .Call(R_igraph_graph_center, graph, mode) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } res } -hrg_consensus_impl <- function(graph, hrg=NULL, start=FALSE, num.samples=10000) { +graph_center_dijkstra_impl <- function(graph, weights=NULL, mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) - if (is.null(hrg)) { - hrg <- list(left=c(), right=c(), prob=c(), edges=c(), vertices=c()) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - hrg <- lapply(hrg[c("left","right","prob","edges","vertices")], as.numeric) - start <- as.logical(start) - num.samples <- as.integer(num.samples) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_hrg_consensus, graph, hrg, start, num.samples) - + res <- .Call(R_igraph_graph_center_dijkstra, graph, weights, mode) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } res } -hrg_create_impl <- function(graph, prob) { +radius_impl <- function(graph, mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) - prob <- as.numeric(prob) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_hrg_create, graph, prob) + res <- .Call(R_igraph_radius, graph, mode) - class(res) <- "igraphHRG" res } -graphlets_impl <- function(graph, weights=NULL, niter=1000) { +radius_dijkstra_impl <- function(graph, weights=NULL, mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -1376,671 +1873,2144 @@ graphlets_impl <- function(graph, weights=NULL, niter=1000) { } else { weights <- NULL } - niter <- as.integer(niter) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_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_radius_dijkstra, graph, weights, mode) + res } -to_directed_impl <- function(graph, mode=c("mutual", "arbitrary", "random", "acyclic")) { +pseudo_diameter_impl <- function(graph, start.vid, directed=TRUE, unconnected=TRUE) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "arbitrary"=0, "mutual"=1, "random"=2, "acyclic"=3) + start.vid <- as_igraph_vs(graph, start.vid) + if (length(start.vid) == 0) { + stop("No vertex was specified") + } + directed <- as.logical(directed) + unconnected <- as.logical(unconnected) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_to_directed, graph, mode) + res <- .Call(R_igraph_pseudo_diameter, graph, start.vid-1, directed, unconnected) res } -dyad_census_impl <- function(graph) { +pseudo_diameter_impl <- function(graph, weights=NULL, start.vid, directed=TRUE, unconnected=TRUE) { # Argument checks ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + start.vid <- as_igraph_vs(graph, start.vid) + if (length(start.vid) == 0) { + stop("No vertex was specified") + } + directed <- as.logical(directed) + unconnected <- as.logical(unconnected) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_dyad_census, graph) + res <- .Call(R_igraph_pseudo_diameter_dijkstra, graph, weights, start.vid-1, directed, unconnected) res } -triad_census_impl <- function(graph) { - # Argument checks - ensure_igraph(graph) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_triad_census, graph) - - res -} - -adjacent_triangles_impl <- function(graph, vids=V(graph)) { +diversity_impl <- function(graph, weights=NULL, vids=V(graph)) { # Argument checks ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } vids <- as_igraph_vs(graph, vids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_adjacent_triangles, graph, vids-1) - + 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 } -list_triangles_impl <- function(graph) { +random_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) { # Argument checks ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + start <- as_igraph_vs(graph, start) + if (length(start) == 0) { + stop("No vertex was specified") + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + steps <- as.numeric(steps) + stuck <- switch(igraph.match.arg(stuck), "error" = 0L, "return" = 1L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_list_triangles, graph) + 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_es(graph, res$edges) } res } -maxflow_impl <- function(graph, source, target, capacity=NULL) { +random_edge_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) { # Argument checks ensure_igraph(graph) - source <- as_igraph_vs(graph, source) - if (length(source) == 0) { - stop("No vertex was specified") - } - target <- as_igraph_vs(graph, target) - if (length(target) == 0) { - stop("No vertex was specified") - } - if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { - capacity <- E(graph)$capacity + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(capacity) && any(!is.na(capacity))) { - capacity <- as.numeric(capacity) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) } else { - capacity <- NULL + weights <- NULL + } + start <- as_igraph_vs(graph, start) + if (length(start) == 0) { + stop("No vertex was specified") } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + steps <- as.numeric(steps) + stuck <- switch(igraph.match.arg(stuck), "error" = 0L, "return" = 1L) 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$partition1 <- create_vs(graph, res$partition1) - } + res <- .Call(R_igraph_random_edge_walk, graph, weights, start-1, mode, steps, stuck) if (igraph_opt("return.vs.es")) { - res$partition2 <- create_vs(graph, res$partition2) + res <- create_es(graph, res) } res } -dominator_tree_impl <- function(graph, root, mode=c("out", "in", "all", "total")) { +global_efficiency_impl <- function(graph, weights=NULL, directed=TRUE) { # Argument checks ensure_igraph(graph) - root <- as_igraph_vs(graph, root) - if (length(root) == 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) + directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_dominator_tree, graph, root-1, mode) - if (igraph_opt("return.vs.es")) { - res$leftout <- create_vs(graph, res$leftout) - } + res <- .Call(R_igraph_global_efficiency, graph, weights, directed) + res } -all_st_cuts_impl <- function(graph, source, target) { +local_efficiency_impl <- function(graph, vids=V(graph), weights=NULL, directed=TRUE, mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) - source <- as_igraph_vs(graph, source) - if (length(source) == 0) { - stop("No vertex was specified") + vids <- as_igraph_vs(graph, vids) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - target <- as_igraph_vs(graph, target) - if (length(target) == 0) { - stop("No vertex was specified") + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL } + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_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 <- .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 } -all_st_mincuts_impl <- function(graph, source, target, capacity=NULL) { +average_local_efficiency_impl <- function(graph, weights=NULL, directed=TRUE, mode=c("all", "out", "in", "total")) { # Argument checks ensure_igraph(graph) - source <- as_igraph_vs(graph, source) - if (length(source) == 0) { - stop("No vertex was specified") - } - target <- as_igraph_vs(graph, target) - if (length(target) == 0) { - stop("No vertex was specified") - } - if (is.null(capacity) && "weight" %in% edge_attr_names(graph)) { - capacity <- E(graph)$weight + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(capacity) && any(!is.na(capacity))) { - capacity <- as.numeric(capacity) + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) } else { - capacity <- NULL + weights <- NULL } + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_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 <- .Call(R_igraph_average_local_efficiency, graph, weights, directed, mode) + res } -is_separator_impl <- function(graph, candidate) { +transitive_closure_dag_impl <- function(graph) { # Argument checks ensure_igraph(graph) - 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_transitive_closure_dag, graph) res } -is_minimal_separator_impl <- function(graph, candidate) { +trussness_impl <- function(graph) { # Argument checks ensure_igraph(graph) - 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_trussness, graph) res } -all_minimal_st_separators_impl <- function(graph) { +is_graphical_impl <- function(out.deg, in.deg=NULL, allowed.edge.types=c("simple", "loops", "multi", "all")) { # Argument checks - ensure_igraph(graph) + out.deg <- as.numeric(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) 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 <- .Call(R_igraph_is_graphical, out.deg, in.deg, allowed.edge.types) + res } -minimum_size_separators_impl <- function(graph) { +bfs_simple_impl <- function(graph, root, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) + root <- as_igraph_vs(graph, root) + if (length(root) == 0) { + stop("No vertex was specified") + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_minimum_size_separators, graph) + res <- .Call(R_igraph_bfs_simple, graph, root-1, mode) 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$order <- create_vs(, res$order) } res } -isoclass_impl <- function(graph) { +bipartite_projection_size_impl <- function(graph, types=NULL) { # Argument checks ensure_igraph(graph) + types <- handle_vertex_type_arg(types, graph) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_isoclass, graph) + res <- .Call(R_igraph_bipartite_projection_size, graph, types) res } -isomorphic_impl <- function(graph1, graph2) { +biadjacency_impl <- function(incidence, directed=FALSE, mode=c("all", "out", "in", "total"), multiple=FALSE) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) + incidence <- as.matrix(structure(as.double(incidence), dim=dim(incidence))) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + multiple <- as.logical(multiple) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_isomorphic, graph1, graph2) - + res <- .Call(R_igraph_biadjacency, incidence, directed, mode, multiple) + if (igraph_opt("add.vertex.names") && is_named()) { + names(res$types) <- vertex_attr(, "name", ) + } res } -isoclass_create_impl <- function(size, number, directed=TRUE) { +get_biadjacency_impl <- function(graph, types=NULL) { # Argument checks - size <- as.integer(size) - number <- as.integer(number) - directed <- as.logical(directed) + ensure_igraph(graph) + types <- handle_vertex_type_arg(types, graph) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_isoclass_create, size, number, directed) + res <- .Call(R_igraph_get_biadjacency, graph, types) res } -isomorphic_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { +is_bipartite_impl <- function(graph) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) - if (missing(vertex.color1)) { - if ("color" %in% vertex_attr_names(graph1)) { - vertex.color1 <- V(graph1)$color - } else { - vertex.color1 <- NULL - } - } - if (!is.null(vertex.color1)) { - vertex.color1 <- as.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 - } + ensure_igraph(graph) 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_is_bipartite, graph) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$type) <- vertex_attr(graph, "name", ) + } res } -count_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { +bipartite_game_impl <- function(type, n1, n2, p=0.0, m=0, directed=FALSE, mode=c("all", "out", "in", "total")) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) - if (missing(vertex.color1)) { - if ("color" %in% vertex_attr_names(graph1)) { - vertex.color1 <- V(graph1)$color - } else { - vertex.color1 <- NULL - } - } - if (!is.null(vertex.color1)) { - vertex.color1 <- as.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 + n1 <- as.numeric(n1) + n2 <- as.numeric(n2) + p <- as.numeric(p) + m <- as.numeric(m) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_bipartite_game, type, n1, n2, p, m, directed, mode) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$types) <- vertex_attr(graph, "name", ) } - if (missing(edge.color1)) { - if ("color" %in% edge_attr_names(graph1)) { - edge.color1 <- E(graph1)$color - } else { - edge.color1 <- NULL - } + res +} + +get_laplacian_impl <- function(graph, mode=c("out", "in", "all", "total"), normalization=UNNORMALIZED, weights=NULL) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(edge.color1)) { - edge.color1 <- as.integer(edge.color1)-1L + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL } - if (missing(edge.color2)) { - if ("color" %in% edge_attr_names(graph2)) { - edge.color2 <- E(graph2)$color - } else { - edge.color2 <- 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 + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight } - if (!is.null(edge.color2)) { - edge.color2 <- as.integer(edge.color2)-1L + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL } on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_isomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + res <- .Call(R_igraph_get_laplacian_sparse, graph, mode, normalization, weights) res } -subisomorphic_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { +is_connected_impl <- function(graph, mode=c("weak", "strong")) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) - if (missing(vertex.color1)) { - if ("color" %in% vertex_attr_names(graph1)) { - vertex.color1 <- V(graph1)$color - } else { - vertex.color1 <- NULL - } - } - if (!is.null(vertex.color1)) { - vertex.color1 <- as.integer(vertex.color1)-1L + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "weak"=1, "strong"=2) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_connected, graph, mode) + + res +} + +articulation_points_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_articulation_points, graph) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) } - if (missing(vertex.color2)) { - if ("color" %in% vertex_attr_names(graph2)) { - vertex.color2 <- V(graph2)$color - } else { - vertex.color2 <- NULL + res +} + +biconnected_components_impl <- function(graph) { + # Argument checks + ensure_igraph(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 (!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 (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 (!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 (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 (!is.null(edge.color2)) { - edge.color2 <- as.integer(edge.color2)-1L + if (igraph_opt("return.vs.es")) { + res$articulation.points <- create_vs(graph, res$articulation.points) } + res +} + +bridges_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) 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_bridges, graph) + if (igraph_opt("return.vs.es")) { + res <- create_es(graph, res) + } res } -count_subisomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { +cliques_impl <- function(graph, min=0, max=0) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) - if (missing(vertex.color1)) { - if ("color" %in% vertex_attr_names(graph1)) { - vertex.color1 <- V(graph1)$color - } else { - vertex.color1 <- NULL - } - } - if (!is.null(vertex.color1)) { - vertex.color1 <- as.integer(vertex.color1)-1L - } - if (missing(vertex.color2)) { - if ("color" %in% vertex_attr_names(graph2)) { - vertex.color2 <- V(graph2)$color - } else { - vertex.color2 <- NULL + ensure_igraph(graph) + min <- as.numeric(min) + max <- as.numeric(max) + + 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) } } - 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 + res +} + +clique_size_hist_impl <- function(graph, min.size=0, max.size=0) { + # Argument checks + ensure_igraph(graph) + min.size <- as.numeric(min.size) + max.size <- as.numeric(max.size) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_clique_size_hist, graph, min.size, max.size) + + res +} + +largest_cliques_impl <- function(graph) { + # Argument checks + ensure_igraph(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) } } - 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 + res +} + +maximal_cliques_subset_impl <- function(graph, subset, outfile=NULL, min.size=0, max.size=0, details=FALSE) { + # Argument checks + ensure_igraph(graph) + subset <- as_igraph_vs(graph, subset) + min.size <- as.numeric(min.size) + max.size <- as.numeric(max.size) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_maximal_cliques_subset, graph, subset-1, outfile, min.size, max.size) + if (igraph_opt("return.vs.es")) { + verts <- V(graph) + for (i_ in seq_along(res$res)) { + res$res[[i_]] <- unsafe_create_vs(graph, res$res[[i_]], verts = verts) } } - if (!is.null(edge.color2)) { - edge.color2 <- as.integer(edge.color2)-1L + if (!details) { + res <- res$res } + res +} + +maximal_cliques_hist_impl <- function(graph, min.size=0, max.size=0) { + # Argument checks + ensure_igraph(graph) + min.size <- as.numeric(min.size) + max.size <- as.numeric(max.size) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_subisomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + res <- .Call(R_igraph_maximal_cliques_hist, graph, min.size, max.size) res } -isomorphic_34_impl <- function(graph1, graph2) { +clique_number_impl <- function(graph) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_clique_number, graph) + + res +} + +weighted_cliques_impl <- function(graph, vertex.weights=NULL, min.weight=0, max.weight=0, maximal=FALSE) { + # Argument checks + ensure_igraph(graph) + if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { + vertex.weights <- V(graph)$weight + } + if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { + vertex.weights <- as.numeric(vertex.weights) + } else { + vertex.weights <- NULL + } + min.weight <- as.numeric(min.weight) + max.weight <- as.numeric(max.weight) + maximal <- as.logical(maximal) + + 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 +} + +largest_weighted_cliques_impl <- function(graph, vertex.weights=NULL) { + # Argument checks + ensure_igraph(graph) + if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { + vertex.weights <- V(graph)$weight + } + if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { + vertex.weights <- as.numeric(vertex.weights) + } else { + vertex.weights <- NULL + } + + 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 +} + +weighted_clique_number_impl <- function(graph, vertex.weights=NULL) { + # Argument checks + ensure_igraph(graph) + if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { + vertex.weights <- V(graph)$weight + } + if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { + vertex.weights <- as.numeric(vertex.weights) + } else { + vertex.weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + 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 + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_roots_for_tree_layout, graph, mode, heuristic) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } + res +} + +layout_umap_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { + # Argument checks + ensure_igraph(graph) + res <- as.matrix(structure(as.double(res), dim=dim(res))) + use.seed <- as.logical(use.seed) + if (!is.null(distances)) distances <- as.numeric(distances) + min.dist <- as.numeric(min.dist) + epochs <- as.numeric(epochs) + distances.are.weights <- as.logical(distances.are.weights) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_umap, graph, res, use.seed, distances, min.dist, epochs, distances.are.weights) + + res +} + +layout_umap_3d_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { + # Argument checks + ensure_igraph(graph) + res <- as.matrix(structure(as.double(res), dim=dim(res))) + use.seed <- as.logical(use.seed) + if (!is.null(distances)) distances <- as.numeric(distances) + min.dist <- as.numeric(min.dist) + epochs <- as.numeric(epochs) + distances.are.weights <- as.logical(distances.are.weights) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_umap_3d, graph, res, use.seed, distances, min.dist, epochs, distances.are.weights) + + res +} + +layout_umap_compute_weights_impl <- function(graph, distances, weights) { + # Argument checks + ensure_igraph(graph) + distances <- as.numeric(distances) + weights <- as.numeric(weights) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_umap_compute_weights, graph, distances, weights) + + res +} + +similarity_dice_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice, graph, vids-1, mode, loops) + + res +} + +similarity_dice_es_impl <- function(graph, es=E(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + es <- as_igraph_es(graph, es) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice_es, graph, es-1, mode, loops) + + res +} + +similarity_dice_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice_pairs, graph, pairs, mode, loops) + + res +} + +similarity_inverse_log_weighted_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_inverse_log_weighted, graph, vids-1, mode) + + res +} + +similarity_jaccard_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard, graph, vids-1, mode, loops) + + res +} + +similarity_jaccard_es_impl <- function(graph, es=E(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + es <- as_igraph_es(graph, es) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard_es, graph, es-1, mode, loops) + + res +} + +similarity_jaccard_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard_pairs, graph, pairs, mode, loops) + + res +} + +graphlets_impl <- function(graph, weights=NULL, niter=1000) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + niter <- as.numeric(niter) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_graphlets, graph, weights, niter) + if (igraph_opt("return.vs.es")) { + verts <- V(graph) + for (i_ in seq_along(res$cliques)) { + res$cliques[[i_]] <- unsafe_create_vs(graph, res$cliques[[i_]], verts = verts) + } + } + res +} + +hrg_sample_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_sample, hrg) + + res +} + +hrg_sample_many_impl <- function(hrg, num.samples) { + # 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) + num.samples <- as.numeric(num.samples) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_sample_many, hrg, num.samples) + + res +} + +hrg_game_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_game, hrg) + + if (igraph_opt("add.params")) { + res$name <- 'Hierarchical random graph model' + } + + res +} + +hrg_consensus_impl <- function(graph, hrg=NULL, start=FALSE, num.samples=10000) { + # Argument checks + ensure_igraph(graph) + if (is.null(hrg)) { + hrg <- list(left=c(), right=c(), prob=c(), edges=c(), vertices=c()) + } + hrg <- lapply(hrg[c("left","right","prob","edges","vertices")], as.numeric) + start <- as.logical(start) + num.samples <- as.numeric(num.samples) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_consensus, graph, hrg, start, num.samples) + + res +} + +hrg_create_impl <- function(graph, prob) { + # Argument checks + ensure_igraph(graph) + prob <- as.numeric(prob) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_create, graph, prob) + + class(res) <- "igraphHRG" + res +} + +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.numeric(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 +} + +from_hrg_dendrogram_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_from_hrg_dendrogram, hrg) + + res +} + +get_adjacency_sparse_impl <- function(graph, type=BOTH, weights=NULL, loops=ONCE) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_adjacency_sparse, graph, type, weights, loops) + + res +} + +get_stochastic_sparse_impl <- function(graph, column.wise=FALSE, weights=NULL) { + # Argument checks + ensure_igraph(graph) + column.wise <- as.logical(column.wise) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_stochastic_sparse, graph, column.wise, weights) + + res +} + +to_directed_impl <- function(graph, mode=c("mutual", "arbitrary", "random", "acyclic")) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "arbitrary"=0, "mutual"=1, "random"=2, "acyclic"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_to_directed, graph, mode) + + 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 + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_dyad_census, graph) + + res +} + +triad_census_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_triad_census, graph) + + res +} + +adjacent_triangles_impl <- function(graph, vids=V(graph)) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_adjacent_triangles, graph, vids-1) + + res +} + +local_scan_subset_ecount_impl <- function(graph, weights=NULL, subsets) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_local_scan_subset_ecount, graph, weights, subsets) + + res +} + +list_triangles_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_list_triangles, graph) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } + res +} + +induced_subgraph_map_impl <- function(graph, vids, impl) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + 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-1, impl) + + res +} + +gomory_hu_tree_impl <- function(graph, capacity=NULL) { + # Argument checks + ensure_igraph(graph) + if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { + capacity <- E(graph)$capacity + } + if (!is.null(capacity) && 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=NULL) { + # Argument checks + ensure_igraph(graph) + source <- as_igraph_vs(graph, source) + if (length(source) == 0) { + stop("No vertex was specified") + } + target <- as_igraph_vs(graph, target) + if (length(target) == 0) { + stop("No vertex was specified") + } + if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { + capacity <- E(graph)$capacity + } + if (!is.null(capacity) && any(!is.na(capacity))) { + capacity <- as.numeric(capacity) + } else { + capacity <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_maxflow, graph, source-1, target-1, capacity) + if (igraph_opt("return.vs.es")) { + res$cut <- create_es(graph, res$cut) + } + if (igraph_opt("return.vs.es")) { + res$partition1 <- create_vs(graph, res$partition1) + } + if (igraph_opt("return.vs.es")) { + res$partition2 <- create_vs(graph, res$partition2) + } + res +} + +residual_graph_impl <- function(graph, capacity, flow) { + # Argument checks + ensure_igraph(graph) + 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 + ensure_igraph(graph) + 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 + ensure_igraph(graph) + root <- as_igraph_vs(graph, root) + if (length(root) == 0) { + stop("No vertex was specified") + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_dominator_tree, graph, root-1, mode) + if (igraph_opt("return.vs.es")) { + res$leftout <- create_vs(graph, res$leftout) + } + res +} + +all_st_cuts_impl <- function(graph, source, target) { + # Argument checks + ensure_igraph(graph) + source <- as_igraph_vs(graph, source) + if (length(source) == 0) { + stop("No vertex was specified") + } + target <- as_igraph_vs(graph, target) + if (length(target) == 0) { + stop("No vertex was specified") + } + + 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) { + # Argument checks + ensure_igraph(graph) + source <- as_igraph_vs(graph, source) + if (length(source) == 0) { + stop("No vertex was specified") + } + target <- as_igraph_vs(graph, target) + if (length(target) == 0) { + stop("No vertex was specified") + } + if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { + capacity <- E(graph)$capacity + } + if (!is.null(capacity) && any(!is.na(capacity))) { + capacity <- as.numeric(capacity) + } else { + capacity <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_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 + ensure_igraph(graph) + + 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 + ensure_igraph(graph) + candidate <- as_igraph_vs(graph, candidate) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_separator, graph, candidate-1) + + res +} + +is_minimal_separator_impl <- function(graph, candidate) { + # Argument checks + ensure_igraph(graph) + 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 +} + +all_minimal_st_separators_impl <- function(graph) { + # Argument checks + ensure_igraph(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 +} + +minimum_size_separators_impl <- function(graph) { + # Argument checks + ensure_igraph(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 +} + +isoclass_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_isoclass, graph) + + res +} + +isomorphic_impl <- function(graph1, graph2) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_isomorphic, graph1, graph2) + + res +} + +isoclass_create_impl <- function(size, number, directed=TRUE) { + # Argument checks + size <- as.numeric(size) + number <- as.numeric(number) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_isoclass_create, size, number, directed) + + res +} + +isomorphic_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, vertex.color2=NULL, edge.color1=NULL, edge.color2=NULL) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-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.numeric(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_isomorphic_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + + res +} + +count_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-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.numeric(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 + ensure_igraph(graph1) + ensure_igraph(graph2) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_subisomorphic, graph1, graph2) + + res +} + +subisomorphic_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, vertex.color2=NULL, edge.color1=NULL, edge.color2=NULL) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-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.numeric(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_subisomorphic_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + + res +} + +subisomorphic_function_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, vertex.color2=NULL, edge.color1=NULL, edge.color2=NULL, ishohandler.fn) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-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.numeric(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_subisomorphic_function_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2, ishohandler.fn) + + res +} + +count_subisomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-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.numeric(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_subisomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + + res +} + +canonical_permutation_impl <- function(graph, colors=NULL, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { + # Argument checks + ensure_igraph(graph) + if (missing(colors)) { + if ("color" %in% vertex_attr_names(graph)) { + colors <- V(graph)$color + } else { + colors <- NULL + } + } + if (!is.null(colors)) { + colors <- as.numeric(colors)-1L + } + sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_canonical_permutation, graph, colors, sh) + + res +} + +permute_vertices_impl <- function(graph, permutation) { + # Argument checks + ensure_igraph(graph) + permutation <- as.numeric(permutation)-1L + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_permute_vertices, graph, permutation) + + res +} + +isomorphic_bliss_impl <- function(graph1, graph2, colors1=NULL, colors2=NULL, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(colors1)) { + if ("color" %in% vertex_attr_names(graph1)) { + colors1 <- V(graph1)$color + } else { + colors1 <- NULL + } + } + if (!is.null(colors1)) { + colors1 <- as.numeric(colors1)-1L + } + if (missing(colors2)) { + if ("color" %in% vertex_attr_names(graph2)) { + colors2 <- V(graph2)$color + } else { + colors2 <- NULL + } + } + if (!is.null(colors2)) { + colors2 <- as.numeric(colors2)-1L + } + sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_isomorphic_bliss, graph1, graph2, colors1, colors2, sh) + + res +} + +automorphisms_impl <- function(graph, colors=NULL, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { + # Argument checks + ensure_igraph(graph) + if (missing(colors)) { + if ("color" %in% vertex_attr_names(graph)) { + colors <- V(graph)$color + } else { + colors <- NULL + } + } + if (!is.null(colors)) { + colors <- as.numeric(colors)-1L + } + sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_automorphisms, graph, colors, sh) + + res +} + +automorphism_group_impl <- function(graph, colors=NULL, sh=c("fm", "f", "fs", "fl", "flm", "fsm"), details=FALSE) { + # Argument checks + ensure_igraph(graph) + if (missing(colors)) { + if ("color" %in% vertex_attr_names(graph)) { + colors <- V(graph)$color + } else { + colors <- NULL + } + } + if (!is.null(colors)) { + colors <- as.numeric(colors)-1L + } + sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + + 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 +} + +graph_count_impl <- function(n, directed=FALSE) { + # Argument checks + n <- as.numeric(n) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_graph_count, n, directed) + + res +} + +adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), scaled=TRUE, cvec=strength(graph, weights=weights)/(vcount(graph)-1), options=arpack_defaults()) { + # Argument checks + ensure_igraph(graph) + no <- as.numeric(no) + 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 + } + which <- switch(igraph.match.arg(which), "lm"=0L, "la"=2L, "sa"=3L) + scaled <- as.logical(scaled) + cvec <- as.numeric(cvec) + options <- modify_list(arpack_defaults(), options) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_adjacency_spectral_embedding, graph, no, weights, which, scaled, cvec, options) + + res +} + +laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), type=c("default", "D-A", "DAD", "I-DAD", "OAP"), scaled=TRUE, options=arpack_defaults()) { + # Argument checks + ensure_igraph(graph) + no <- as.numeric(no) + 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 + } + which <- switch(igraph.match.arg(which), "lm"=0L, "la"=2L, "sa"=3L) + type <- switch(igraph.match.arg(type), + "default"=if (is.directed(graph)) 3L else 0L, + "da"=0L, "d-a"=0L, "idad"=1L, "i-dad"=1L, "dad"=2L, + "oap"=3L) + scaled <- as.logical(scaled) + options <- modify_list(arpack_defaults(), options) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_laplacian_spectral_embedding, graph, no, weights, which, type, scaled, options) + + res +} + +eigen_adjacency_impl <- function(graph, algorithm=c("arpack", "auto", "lapack", "comp_auto", "comp_lapack", "comp_arpack"), which=list(), options=arpack_defaults()) { + # Argument checks + ensure_igraph(graph) + 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 <- modify_list(arpack_defaults(), options) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_eigen_adjacency, graph, algorithm, which, options) + + res +} + +sir_impl <- function(graph, beta, gamma, no.sim=100) { + # Argument checks + ensure_igraph(graph) + beta <- as.numeric(beta) + gamma <- as.numeric(gamma) + no.sim <- as.numeric(no.sim) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_sir, graph, beta, gamma, no.sim) + + class(res) <- "sir" + res +} + +convex_hull_impl <- function(data) { + # Argument checks + data <- as.matrix(structure(as.double(data), dim=dim(data))) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_convex_hull, data) + + res +} + +dim_select_impl <- function(sv) { + # Argument checks + sv <- as.numeric(sv) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_dim_select, 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))) + requireNamespace("Matrix", quietly = TRUE); 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 <- modify_list(arpack_defaults(), options) + + 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))) + requireNamespace("Matrix", quietly = TRUE); 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 <- modify_list(arpack_defaults(), options) + + 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.numeric(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 + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_eulerian, graph) + + res +} + +eulerian_path_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_eulerian_path, graph) + if (igraph_opt("return.vs.es")) { + res$epath <- create_es(graph, res$epath) + } + if (igraph_opt("return.vs.es")) { + res$vpath <- create_vs(graph, res$vpath) + } + res +} + +eulerian_cycle_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_eulerian_cycle, graph) + if (igraph_opt("return.vs.es")) { + res$epath <- create_es(graph, res$epath) + } + if (igraph_opt("return.vs.es")) { + res$vpath <- create_vs(graph, res$vpath) + } + res +} + +fundamental_cycles_impl <- function(graph, start=NULL, bfs.cutoff, weights=NULL) { + # Argument checks + ensure_igraph(graph) + if (!is.null(start)) start <- as_igraph_vs(graph, start) + if (length(start) == 0) { + stop("No vertex was specified") + } + bfs.cutoff <- as.numeric(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) + if (igraph_opt("return.vs.es")) { + es <- E(graph) + for (i_ in seq_along(res)) { + res[[i_]] <- unsafe_create_es(graph, res[[i_]], es = es) + } + } + res +} + +minimum_cycle_basis_impl <- function(graph, bfs.cutoff, complete, use.cycle.order, weights=NULL) { + # Argument checks + ensure_igraph(graph) + bfs.cutoff <- as.numeric(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) + if (igraph_opt("return.vs.es")) { + es <- E(graph) + for (i_ in seq_along(res)) { + res[[i_]] <- unsafe_create_es(graph, res[[i_]], es = es) + } + } + res +} + +is_tree_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FALSE) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_isomorphic_34, graph1, graph2) - + res <- .Call(R_igraph_is_tree, graph, mode) + if (igraph_opt("return.vs.es") && vcount(graph) != 0) { + res$root <- create_vs(graph, res$root) + } + if (!details) { + res <- res$res + } res } -canonical_permutation_impl <- function(graph, colors, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { +is_forest_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FALSE) { # Argument checks ensure_igraph(graph) - if (missing(colors)) { - if ("color" %in% vertex_attr_names(graph)) { - colors <- V(graph)$color - } else { - colors <- NULL - } - } - if (!is.null(colors)) { - colors <- as.integer(colors)-1L - } - sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_canonical_permutation, graph, colors, sh) - + 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 } -permute_vertices_impl <- function(graph, permutation) { +from_prufer_impl <- function(prufer) { # Argument checks - ensure_igraph(graph) - permutation <- as.numeric(permutation)-1 + prufer <- as.numeric(prufer)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_permute_vertices, graph, permutation) + res <- .Call(R_igraph_from_prufer, prufer) + + if (igraph_opt("add.params")) { + res$name <- 'Tree from Prufer sequence' + res$prufer <- prufer + } res } -isomorphic_bliss_impl <- function(graph1, graph2, colors1, colors2, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { +to_prufer_impl <- function(graph) { # Argument checks - ensure_igraph(graph1) - ensure_igraph(graph2) - if (missing(colors1)) { - if ("color" %in% vertex_attr_names(graph1)) { - colors1 <- V(graph1)$color - } else { - colors1 <- NULL - } - } - if (!is.null(colors1)) { - colors1 <- as.integer(colors1)-1L - } - if (missing(colors2)) { - if ("color" %in% vertex_attr_names(graph2)) { - colors2 <- V(graph2)$color - } else { - colors2 <- NULL - } - } - if (!is.null(colors2)) { - colors2 <- as.integer(colors2)-1L - } - sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + ensure_igraph(graph) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_isomorphic_bliss, graph1, graph2, colors1, colors2, sh) + res <- .Call(R_igraph_to_prufer, graph) res } -automorphisms_impl <- function(graph, colors, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { +tree_from_parent_vector_impl <- function(parents, type=OUT) { # Argument checks - ensure_igraph(graph) - if (missing(colors)) { - if ("color" %in% vertex_attr_names(graph)) { - colors <- V(graph)$color - } else { - colors <- NULL - } - } - if (!is.null(colors)) { - colors <- as.integer(colors)-1L - } - sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) + parents <- as.numeric(parents)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_automorphisms, graph, colors, sh) + res <- .Call(R_igraph_tree_from_parent_vector, parents, type) res } -automorphism_group_impl <- function(graph, colors, sh=c("fm", "f", "fs", "fl", "flm", "fsm"), details=FALSE) { +random_spanning_tree_impl <- function(graph, vid=0) { # Argument checks ensure_igraph(graph) - if (missing(colors)) { - if ("color" %in% vertex_attr_names(graph)) { - colors <- V(graph)$color - } else { - colors <- NULL - } - } - if (!is.null(colors)) { - colors <- as.integer(colors)-1L + if (!is.null(vid)) vid <- as_igraph_vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") } - sh <- switch(igraph.match.arg(sh), "f"=0, "fl"=1, "fs"=2, "fm"=3, "flm"=4, "fsm"=5) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_automorphism_group, graph, colors, sh) + res <- .Call(R_igraph_random_spanning_tree, graph, vid-1) 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 <- create_es(graph, res) } res } -scg_norm_eps_impl <- function(V, groups, mtype=c("symmetric", "laplacian", "stochastic"), p=NULL, norm=c("row", "col")) { +tree_game_impl <- function(n, directed=FALSE, method=c("lerw", "prufer")) { # 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.numeric(n) + directed <- as.logical(directed) + method <- switch(igraph.match.arg(method), "prufer"=0L, "lerw"=1L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_scg_norm_eps, V, groups, mtype, p, norm) + res <- .Call(R_igraph_tree_game, n, directed, method) res } -adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), scaled=TRUE, cvec=strength(graph, weights=weights)/(vcount(graph)-1), options=arpack_defaults()) { +vertex_coloring_greedy_impl <- function(graph, heuristic=c("colored_neighbors", "dsatur")) { # Argument checks ensure_igraph(graph) - no <- as.integer(no) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight + heuristic <- switch(igraph.match.arg(heuristic), "colored_neighbors"=0L, "dsatur"=1L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_vertex_coloring_greedy, graph, heuristic) + res <- res+1L + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res) <- vertex_attr(graph, "name") } - if (!is.null(weights) && any(!is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL + res +} + +deterministic_optimal_imitation_impl <- function(graph, vid, optimality=MAXIMUM, quantities, strategies, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + vid <- as_igraph_vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") } - which <- switch(igraph.match.arg(which), "lm"=0L, "la"=2L, "sa"=3L) - scaled <- as.logical(scaled) - cvec <- as.numeric(cvec) - options <- modify_list(arpack_defaults(), options) + strategies <- as.numeric(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_adjacency_spectral_embedding, graph, no, weights, which, scaled, cvec, options) + res <- .Call(R_igraph_deterministic_optimal_imitation, graph, vid-1, optimality, quantities, strategies, mode) res } -laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), type=c("default", "D-A", "DAD", "I-DAD", "OAP"), scaled=TRUE, options=arpack_defaults()) { +moran_process_impl <- function(graph, weights=NULL, quantities, strategies, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - no <- as.integer(no) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -2049,204 +4019,154 @@ laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c(" } else { weights <- NULL } - which <- switch(igraph.match.arg(which), "lm"=0L, "la"=2L, "sa"=3L) - type <- switch(igraph.match.arg(type), - "default"=if (is.directed(graph)) 3L else 0L, - "da"=0L, "d-a"=0L, "idad"=1L, "i-dad"=1L, "dad"=2L, - "oap"=3L) - scaled <- as.logical(scaled) - options <- modify_list(arpack_defaults(), options) + strategies <- as.numeric(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_laplacian_spectral_embedding, graph, no, weights, which, type, scaled, options) - + res <- .Call(R_igraph_moran_process, graph, weights, quantities, strategies, mode) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$quantities) <- vertex_attr(graph, "name", ) + } res } -eigen_adjacency_impl <- function(graph, algorithm=c("arpack", "auto", "lapack", "comp_auto", "comp_lapack", "comp_arpack"), which=list(), options=arpack_defaults()) { +roulette_wheel_imitation_impl <- function(graph, vid, is.local, quantities, strategies, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - 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 <- modify_list(arpack_defaults(), options) + vid <- as_igraph_vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") + } + is.local <- as.logical(is.local) + strategies <- as.numeric(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_eigen_adjacency, graph, algorithm, which, options) + res <- .Call(R_igraph_roulette_wheel_imitation, graph, vid-1, is.local, quantities, strategies, mode) res } -sir_impl <- function(graph, beta, gamma, no.sim=100) { +stochastic_imitation_impl <- function(graph, vid, algo, quantities, strategies, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - beta <- as.numeric(beta) - gamma <- as.numeric(gamma) - no.sim <- as.integer(no.sim) + vid <- as_igraph_vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") + } + strategies <- as.numeric(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_sir, graph, beta, gamma, no.sim) + res <- .Call(R_igraph_stochastic_imitation, graph, vid-1, algo, quantities, strategies, mode) - class(res) <- "sir" res } -convex_hull_impl <- function(data) { +has_attribute_table_impl <- function() { # Argument checks - data <- as.matrix(structure(as.double(data), dim=dim(data))) + on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_convex_hull, data) + res <- .Call(R_igraph_has_attribute_table, ) + res } -dim_select_impl <- function(sv) { +progress_impl <- function(message, percent) { # Argument checks - sv <- as.numeric(sv) + percent <- as.numeric(percent) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_dim_select, sv) + res <- .Call(R_igraph_progress, message, percent) + res } -is_eulerian_impl <- function(graph) { +status_impl <- function(message) { # Argument checks - ensure_igraph(graph) + on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_eulerian, graph) + res <- .Call(R_igraph_status, message) + res } -eulerian_path_impl <- function(graph) { +strerror_impl <- function(igraph.errno) { # Argument checks - ensure_igraph(graph) + on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_eulerian_path, graph) - if (igraph_opt("return.vs.es")) { - res$epath <- create_es(graph, res$epath) - } - if (igraph_opt("return.vs.es")) { - res$vpath <- create_vs(graph, res$vpath) - } - res -} + res <- .Call(R_igraph_strerror, igraph.errno) -eulerian_cycle_impl <- function(graph) { - # Argument checks - ensure_igraph(graph) - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_eulerian_cycle, graph) - if (igraph_opt("return.vs.es")) { - res$epath <- create_es(graph, res$epath) - } - if (igraph_opt("return.vs.es")) { - res$vpath <- create_vs(graph, res$vpath) - } res } -is_tree_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FALSE) { +vertex_path_from_edge_path_impl <- function(graph, start, edge.path, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + start <- as_igraph_vs(graph, start) + if (length(start) == 0) { + stop("No vertex was specified") + } + edge.path <- as_igraph_es(graph, edge.path) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_tree, graph, mode) + res <- .Call(R_igraph_vertex_path_from_edge_path, graph, start-1, edge.path-1, mode) if (igraph_opt("return.vs.es")) { - res$root <- create_vs(graph, res$root) - } - if (!details) { - res <- res$res + res <- create_vs(, res) } res } -from_prufer_impl <- function(prufer) { +version_impl <- function() { # Argument checks - prufer <- as.integer(prufer)-1L + on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_from_prufer, prufer) - - if (igraph_opt("add.params")) { - res$name <- 'Tree from Prufer sequence' - res$prufer <- prufer - } + res <- .Call(R_igraph_version, ) res } -to_prufer_impl <- function(graph) { +get_stochastic_sparsemat_impl <- function(graph, column.wise=FALSE) { # Argument checks ensure_igraph(graph) + column.wise <- as.logical(column.wise) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_to_prufer, graph) - res <- res+1 - res -} - -random_spanning_tree_impl <- function(graph, vid=0) { - # Argument checks - ensure_igraph(graph) - vid <- as_igraph_vs(graph, vid) - if (length(vid) == 0) { - stop("No vertex was specified") - } + res <- .Call(R_igraph_get_stochastic_sparsemat, graph, column.wise) - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_random_spanning_tree, graph, vid-1) - if (igraph_opt("return.vs.es")) { - res <- create_es(graph, res) - } res } -tree_game_impl <- function(n, directed=FALSE, method=c("lerw", "prufer")) { +hrg_dendrogram_impl <- function(hrg) { # Argument checks - n <- as.integer(n) - directed <- as.logical(directed) - method <- switch(igraph.match.arg(method), "prufer"=0L, "lerw"=1L) + 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_tree_game, n, directed, method) - - res -} - -vertex_coloring_greedy_impl <- function(graph, heuristic=c("colored_neighbors")) { - # Argument checks - ensure_igraph(graph) - heuristic <- switch(igraph.match.arg(heuristic), "colored_neighbors"=0L) + res <- .Call(R_igraph_hrg_dendrogram, hrg) - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_vertex_coloring_greedy, graph, heuristic) - res <- res+1L - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name") - } res } diff --git a/R/adjacency.R b/R/adjacency.R index 98bb6ad2fee..34ff76f6863 100644 --- a/R/adjacency.R +++ b/R/adjacency.R @@ -22,48 +22,49 @@ ## ## ----------------------------------------------------------------- -graph.adjacency.dense <- function(adjmatrix, mode, weighted = NULL, diag = TRUE) { +graph.adjacency.dense <- function( + adjmatrix, + mode, + weighted = NULL, + diag = c("once", "twice", "ignore")) { mode <- switch(mode, - "directed" = 0, - "undirected" = 1, - "max" = 1, - "upper" = 2, - "lower" = 3, - "min" = 4, - "plus" = 5 + "directed" = 0L, + "undirected" = 1L, + "upper" = 2L, + "lower" = 3L, + "min" = 4L, + "plus" = 5L, + "max" = 6L ) - mode(adjmatrix) <- "double" - - if (!is.null(weighted)) { - if (is.logical(weighted) && weighted) { - weighted <- "weight" - } - if (!is.character(weighted)) { - stop("invalid value supplied for `weighted' argument, please see docs.") - } + if (is.logical(diag)) { + diag <- ifelse(diag, "once", "ignore") + } + diag <- igraph.match.arg(diag) + diag <- switch(diag, + "ignore" = 0L, + "twice" = 1L, + "once" = 2L + ) - if (nrow(adjmatrix) != ncol(adjmatrix)) { - stop("not a square matrix") - } + if (nrow(adjmatrix) != ncol(adjmatrix)) { + stop("Adjacency matrices must be square.") + } - on.exit(.Call(R_igraph_finalizer)) - res <- .Call( - R_igraph_weighted_adjacency, adjmatrix, - as.numeric(mode), weighted, diag - ) - } else { - adjmatrix <- as.matrix(adjmatrix) - attrs <- attributes(adjmatrix) - adjmatrix <- as.numeric(adjmatrix) - attributes(adjmatrix) <- attrs + mode(adjmatrix) <- "double" - if (!diag) { - diag(adjmatrix) <- 0 - } + if (isTRUE(weighted)) { + weighted <- "weight" + } else if (!is.character(weighted)) { + weighted <- NULL + } - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_graph_adjacency, adjmatrix, as.numeric(mode)) + on.exit(.Call(R_igraph_finalizer)) + if (is.null(weighted)) { + res <- .Call(R_igraph_adjacency, adjmatrix, mode, diag) + } else { + res <- .Call(R_igraph_weighted_adjacency, adjmatrix, mode, diag) + res <- set_edge_attr(res$graph, weighted, value = res$weights) } res diff --git a/R/assortativity.R b/R/assortativity.R index 262e45f95a4..e46a0513eeb 100644 --- a/R/assortativity.R +++ b/R/assortativity.R @@ -86,6 +86,7 @@ #' `TRUE` here to do the natural thing, i.e. use directed version of the #' measure for directed graphs and the undirected version for undirected #' graphs. +#' @param normalized TBD #' @param types1,types2 #' `r lifecycle::badge("deprecated")` #' Deprecated aliases for `values` and `values.in`, respectively. @@ -110,6 +111,7 @@ assortativity <- function(graph, ..., values.in = NULL, directed = TRUE, + normalized = TRUE, types1 = NULL, types2 = NULL) { if (...length() > 0) { @@ -153,7 +155,7 @@ assortativity <- function(graph, values.in <- types2 } - assortativity_impl(graph, values, values.in, directed) + assortativity_impl(graph, values, values.in, directed, normalized) } assortativity_legacy <- function(graph, types1, types2 = NULL, directed = TRUE) { diff --git a/R/bipartite.R b/R/bipartite.R index 46250da34c4..fd580f78190 100644 --- a/R/bipartite.R +++ b/R/bipartite.R @@ -117,7 +117,7 @@ bipartite_projection <- function(graph, types = NULL, # Function call res <- .Call( R_igraph_bipartite_projection, graph, types, - as.integer(probe1), which + as.numeric(probe1), which ) if (remove.type) { if (is_igraph(res[[1]])) { diff --git a/R/centrality.R b/R/centrality.R index 1f2da59977b..24f3adabaed 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -583,7 +583,7 @@ arpack.unpack.complex <- function(vectors, values, nev) { # Argument checks vectors <- as.matrix(structure(as.double(vectors), dim = dim(vectors))) values <- as.matrix(structure(as.double(values), dim = dim(values))) - nev <- as.integer(nev) + nev <- as.numeric(nev) on.exit(.Call(R_igraph_finalizer)) # Function call diff --git a/R/centralization.R b/R/centralization.R index 8ca23ecd854..4ea744e3ff3 100644 --- a/R/centralization.R +++ b/R/centralization.R @@ -155,7 +155,7 @@ centr_degree_tmax <- function(graph = NULL, nodes = 0, mode = c("all", "out", "i # Argument checks ensure_igraph(graph, optional = TRUE) - nodes <- as.integer(nodes) + nodes <- as.numeric(nodes) mode <- switch(igraph.match.arg(mode), "out" = 1, "in" = 2, diff --git a/R/cliques.R b/R/cliques.R index 12832db2b52..c2ebcb3182c 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -115,7 +115,7 @@ max_cliques <- function(graph, min = NULL, max = NULL, subset = NULL, file = NUL } if (!is.null(subset)) { - subset <- as.integer(as_igraph_vs(graph, subset) - 1) + subset <- as.numeric(as_igraph_vs(graph, subset) - 1) } if (!is.null(file)) { @@ -167,11 +167,11 @@ count_max_cliques <- function(graph, min = NULL, max = NULL, if (is.null(max)) { max <- 0 } - min <- as.integer(min) - max <- as.integer(max) + min <- as.numeric(min) + max <- as.numeric(max) if (!is.null(subset)) { - subset <- as.integer(as_igraph_vs(graph, subset) - 1) + subset <- as.numeric(as_igraph_vs(graph, subset) - 1) } on.exit(.Call(R_igraph_finalizer)) diff --git a/R/community.R b/R/community.R index 82059f69f95..d75a90bfe30 100644 --- a/R/community.R +++ b/R/community.R @@ -1134,15 +1134,13 @@ cluster_leiden <- function(graph, objective_function = c("CPM", "modularity"), on.exit(.Call(R_igraph_finalizer)) membership <- initial_membership if (n_iterations > 0) { - for (i in 1:n_iterations) { - res <- .Call( - R_igraph_community_leiden, graph, weights, - vertex_weights, as.numeric(resolution_parameter), - as.numeric(beta), !is.null(membership), - membership - ) - membership <- res$membership - } + res <- .Call( + R_igraph_community_leiden, graph, weights, + vertex_weights, as.numeric(resolution_parameter), + as.numeric(beta), !is.null(membership), as.numeric(n_iterations), + membership + ) + membership <- res$membership } else { prev_quality <- -Inf quality <- 0.0 @@ -1151,7 +1149,7 @@ cluster_leiden <- function(graph, objective_function = c("CPM", "modularity"), res <- .Call( R_igraph_community_leiden, graph, weights, vertex_weights, as.numeric(resolution_parameter), - as.numeric(beta), !is.null(membership), + as.numeric(beta), !is.null(membership), 1, membership ) membership <- res$membership @@ -1209,18 +1207,19 @@ cluster_fluid_communities <- function(graph, no.of.communities) { # Argument checks ensure_igraph(graph) - no.of.communities <- as.integer(no.of.communities) + no.of.communities <- as.numeric(no.of.communities) on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_community_fluid_communities, graph, no.of.communities) + membership <- .Call(R_igraph_community_fluid_communities, graph, no.of.communities) + res <- list() + res$membership <- membership + 1 if (igraph_opt("add.vertex.names") && is_named(graph)) { res$names <- V(graph)$name } res$vcount <- vcount(graph) res$algorithm <- "fluid communities" - res$membership <- res$membership + 1 class(res) <- "communities" res } @@ -1638,7 +1637,7 @@ cluster_leading_eigen <- function(graph, steps = -1, weights = NULL, # Argument checks ensure_igraph(graph) - steps <- as.integer(steps) + steps <- as.numeric(steps) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -1692,7 +1691,10 @@ cluster_leading_eigen <- function(graph, steps = -1, weights = NULL, #' communities.} #' #' @aliases label.propagation.community -#' @param graph The input graph, should be undirected to make sense. +#' @param graph The input graph. Note that the algorithm wsa originally +#' defined for undirected graphs. You are advised to set \sQuote{mode} to +#' `all` if you pass a directed graph here to treat it as +#' undirected. #' @param weights The weights of the edges. It must be a positive numeric vector, #' `NULL` or `NA`. If it is `NULL` and the input graph has a #' \sQuote{weight} edge attribute, then that attribute will be used. If @@ -1734,6 +1736,7 @@ cluster_label_prop <- function( graph, weights = NULL, ..., + mode = c("out", "in", "all"), initial = NULL, fixed = NULL) { if (...length() > 0) { @@ -1756,12 +1759,13 @@ cluster_label_prop <- function( return(inject(cluster_label_prop0(!!!dots))) } - cluster_label_prop0(graph, weights, initial, fixed) + cluster_label_prop0(graph, weights, mode, initial, fixed) } cluster_label_prop0 <- function( graph, weights = NULL, + mode = c("out", "in", "all"), initial = NULL, fixed = NULL) { # Argument checks @@ -1778,15 +1782,20 @@ cluster_label_prop0 <- function( if (!is.null(initial)) initial <- as.numeric(initial) if (!is.null(fixed)) fixed <- as.logical(fixed) + directed <- switch(igraph.match.arg(mode), "out"=TRUE, "in"=TRUE, "all"=FALSE) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3) + on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_community_label_propagation, graph, weights, initial, fixed) + membership <- .Call(R_igraph_community_label_propagation, graph, mode, weights, initial, fixed) + res <- list() if (igraph_opt("add.vertex.names") && is_named(graph)) { res$names <- V(graph)$name } res$vcount <- vcount(graph) res$algorithm <- "label propagation" - res$membership <- res$membership + 1 + res$membership <- membership + 1 + res$modularity <- modularity(graph, res$membership, weights, directed) class(res) <- "communities" res } @@ -2046,7 +2055,7 @@ cluster_infomap <- function(graph, e.weights = NULL, v.weights = NULL, } else { v.weights <- NULL } - nb.trials <- as.integer(nb.trials) + nb.trials <- as.numeric(nb.trials) on.exit(.Call(R_igraph_finalizer)) # Function call diff --git a/R/conversion.R b/R/conversion.R index ca0b1c3bc94..b3d9dd2f8c9 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -20,7 +20,7 @@ ################################################################### get.adjacency.dense <- function(graph, type = c("both", "upper", "lower"), - attr = NULL, edges = FALSE, names = TRUE) { + attr = NULL, weights = NULL, loops = FALSE, names = TRUE) { ensure_igraph(graph) type <- igraph.match.arg(type) @@ -30,11 +30,13 @@ get.adjacency.dense <- function(graph, type = c("both", "upper", "lower"), "both" = 2 ) - if (edges || is.null(attr)) { + if (!is.null(weights)) weights <- as.numeric(weights) + + if (is.null(attr)) { on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_get_adjacency, graph, as.numeric(type), - as.logical(edges) + R_igraph_get_adjacency, graph, as.numeric(type), weights, + as.logical(loops) ) } else { attr <- as.character(attr) @@ -215,7 +217,7 @@ as_adjacency_matrix <- function(graph, type = c("both", "upper", "lower"), } if (!sparse) { - get.adjacency.dense(graph, type = type, attr = attr, edges = edges, names = names) + get.adjacency.dense(graph, type = type, attr = attr, weights = NULL, names = names) } else { get.adjacency.sparse(graph, type = type, attr = attr, edges = edges, names = names) } @@ -705,14 +707,14 @@ 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] - colnames(res$res) <- V(graph)$name[res$col_ids + 1] + rownames(res$res) <- V(graph)$name[res$row_ids] + colnames(res$res) <- V(graph)$name[res$col_ids] } else { - rownames(res$res) <- res$row_ids + 1 - colnames(res$res) <- res$col_ids + 1 + rownames(res$res) <- res$row_ids + colnames(res$res) <- res$col_ids } res$res } else { diff --git a/R/demo.R b/R/demo.R index 523a1bd0563..a18a2631504 100644 --- a/R/demo.R +++ b/R/demo.R @@ -45,7 +45,7 @@ #' @examples #' #' igraph_demo() -#' if (interactive()) { +#' if (interactive() && requireNamespace("tcltk", quietly = TRUE)) { #' igraph_demo("centrality") #' } #' diff --git a/R/embedding.R b/R/embedding.R index 809ec0ce57f..5570c997278 100644 --- a/R/embedding.R +++ b/R/embedding.R @@ -263,8 +263,8 @@ embed_laplacian_matrix <- laplacian_spectral_embedding_impl #' vec.norm sample_sphere_surface <- function(dim, n = 1, radius = 1, positive = TRUE) { # Argument checks - dim <- as.integer(dim) - n <- as.integer(n) + dim <- as.numeric(dim) + n <- as.numeric(n) radius <- as.numeric(radius) positive <- as.logical(positive) @@ -305,8 +305,8 @@ sample_sphere_surface <- function(dim, n = 1, radius = 1, positive = TRUE) { #' vec.norm sample_sphere_volume <- function(dim, n = 1, radius = 1, positive = TRUE) { # Argument checks - dim <- as.integer(dim) - n <- as.integer(n) + dim <- as.numeric(dim) + n <- as.numeric(n) radius <- as.numeric(radius) positive <- as.logical(positive) @@ -342,7 +342,7 @@ sample_sphere_volume <- function(dim, n = 1, radius = 1, positive = TRUE) { #' colSums(lpvs.dir) sample_dirichlet <- function(n, alpha) { # Argument checks - n <- as.integer(n) + n <- as.numeric(n) alpha <- as.numeric(alpha) on.exit(.Call(R_igraph_finalizer)) diff --git a/R/games.R b/R/games.R index d9fa0c75ecd..8054674221c 100644 --- a/R/games.R +++ b/R/games.R @@ -985,7 +985,7 @@ sample_pref <- function(nodes, types, type.dist = rep(1, types), on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_preference_game, as.integer(nodes), as.integer(types), + R_igraph_preference_game, as.numeric(nodes), as.numeric(types), as.double(type.dist), as.logical(fixed.sizes), matrix(as.double(pref.matrix), types, types), as.logical(directed), as.logical(loops) @@ -1024,7 +1024,7 @@ sample_asym_pref <- function(nodes, types, on.exit(.Call(R_igraph_finalizer)) res <- .Call( R_igraph_asymmetric_preference_game, - as.integer(nodes), as.integer(types), as.integer(types), + as.numeric(nodes), as.numeric(types), as.numeric(types), matrix(as.double(type.dist.matrix), types, types), matrix(as.double(pref.matrix), types, types), as.logical(loops) @@ -1300,14 +1300,14 @@ cit_cit_types <- function(...) constructor_spec(sample_cit_cit_types, ...) #' sample_bipartite <- function(n1, n2, type = c("gnp", "gnm"), p, m, directed = FALSE, mode = c("out", "in", "all")) { - n1 <- as.integer(n1) - n2 <- as.integer(n2) + n1 <- as.numeric(n1) + n2 <- as.numeric(n2) type <- igraph.match.arg(type) if (!missing(p)) { p <- as.numeric(p) } if (!missing(m)) { - m <- as.integer(m) + m <- as.numeric(m) } directed <- as.logical(directed) mode <- switch(igraph.match.arg(mode), diff --git a/R/glet.R b/R/glet.R index 23d396463d4..47b8d935792 100644 --- a/R/glet.R +++ b/R/glet.R @@ -115,7 +115,7 @@ graphlet_proj <- function(graph, weights = NULL, cliques, niter = 1000, weights <- NULL } Mu <- as.numeric(Mu) - niter <- as.integer(niter) + niter <- as.numeric(niter) on.exit(.Call(R_igraph_finalizer)) # Function call diff --git a/R/hrg.R b/R/hrg.R index c0626d2671f..68cc8249e32 100644 --- a/R/hrg.R +++ b/R/hrg.R @@ -126,7 +126,7 @@ fit_hrg <- function(graph, hrg = NULL, start = FALSE, steps = 0) { as.numeric ) start <- as.logical(start) - steps <- as.integer(steps) + steps <- as.numeric(steps) on.exit(.Call(R_igraph_finalizer)) # Function call @@ -292,8 +292,8 @@ predict_edges <- function(graph, hrg = NULL, start = FALSE, num.samples = 10000, as.numeric ) start <- as.logical(start) - num.samples <- as.integer(num.samples) - num.bins <- as.integer(num.bins) + num.samples <- as.numeric(num.samples) + num.bins <- as.numeric(num.bins) on.exit(.Call(R_igraph_finalizer)) # Function call diff --git a/R/interface.R b/R/interface.R index 29c011197ca..2fb5b7d3825 100644 --- a/R/interface.R +++ b/R/interface.R @@ -481,7 +481,7 @@ get.edge.ids <- function(graph, vp, directed = TRUE, error = FALSE, multi = FALS #' gorder(g) #' vcount(g) vcount <- function(graph) { - as.integer(vcount_impl(graph)) + as.numeric(vcount_impl(graph)) } #' @export diff --git a/R/layout.R b/R/layout.R index 15b9973ccca..78078586351 100644 --- a/R/layout.R +++ b/R/layout.R @@ -287,7 +287,7 @@ layout_as_bipartite <- function(graph, types = NULL, hgap = 1, vgap = 1, types <- handle_vertex_type_arg(types, graph) hgap <- as.numeric(hgap) vgap <- as.numeric(vgap) - maxiter <- as.integer(maxiter) + maxiter <- as.numeric(maxiter) on.exit(.Call(R_igraph_finalizer)) @@ -653,17 +653,17 @@ nicely <- function(...) layout_spec(layout_nicely, ...) #' layout_on_grid(g2, dim = 3) #' #' plot(g, layout = layout_on_grid) -#' if (interactive()) { +#' if (interactive() && requireNamespace("rgl", quietly = TRUE)) { #' rglplot(g, layout = layout_on_grid(g, dim = 3)) #' } layout_on_grid <- function(graph, width = 0, height = 0, dim = 2) { # Argument checks ensure_igraph(graph) - width <- as.integer(width) - dim <- as.integer(dim) + width <- as.numeric(width) + dim <- as.numeric(dim) stopifnot(dim == 2 || dim == 3) if (dim == 3) { - height <- as.integer(height) + height <- as.numeric(height) } on.exit(.Call(R_igraph_finalizer)) @@ -694,8 +694,8 @@ layout.grid.3d <- function(graph, width = 0, height = 0) { )) # Argument checks ensure_igraph(graph) - width <- as.integer(width) - height <- as.integer(height) + width <- as.numeric(width) + height <- as.numeric(height) on.exit(.Call(R_igraph_finalizer)) # Function call @@ -917,8 +917,8 @@ layout_with_dh <- function(graph, coords = NULL, maxiter = 10, coords <- matrix(NA_real_, ncol = 2, nrow = 0) use.seed <- FALSE } - maxiter <- as.integer(maxiter) - fineiter <- as.integer(fineiter) + maxiter <- as.numeric(maxiter) + fineiter <- as.numeric(fineiter) cool.fact <- as.numeric(cool.fact) weight.node.dist <- as.numeric(weight.node.dist) weight.border <- as.numeric(weight.border) @@ -1036,7 +1036,7 @@ layout_with_fr <- function(graph, coords = NULL, dim = 2, if (!is.null(coords)) { coords <- as.matrix(structure(as.double(coords), dim = dim(coords))) } - dim <- as.integer(dim) + dim <- as.numeric(dim) if (dim != 2L && dim != 3L) { stop("Dimension must be two or three") } @@ -1044,7 +1044,7 @@ layout_with_fr <- function(graph, coords = NULL, dim = 2, stop("Both `niter' and `maxiter' are given, give only one of them") } if (!missing(maxiter)) niter <- maxiter - niter <- as.integer(niter) + niter <- as.numeric(niter) start.temp <- as.numeric(start.temp) grid <- igraph.match.arg(grid) @@ -1164,7 +1164,7 @@ layout_with_gem <- function(graph, coords = NULL, maxiter = 40 * vcount(graph)^2 use.seed <- FALSE } - maxiter <- as.integer(maxiter) + maxiter <- as.numeric(maxiter) temp.max <- as.numeric(temp.max) temp.min <- as.numeric(temp.min) temp.init <- as.numeric(temp.init) @@ -1339,12 +1339,12 @@ layout_with_kk <- function(graph, coords = NULL, dim = 2, if (!is.null(coords)) { coords <- as.matrix(structure(as.double(coords), dim = dim(coords))) } - dim <- as.integer(dim) + dim <- as.numeric(dim) if (dim != 2L && dim != 3L) { stop("Dimension must be two or three") } - maxiter <- as.integer(maxiter) + maxiter <- as.numeric(maxiter) epsilon <- as.numeric(epsilon) kkconst <- as.numeric(kkconst) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -1531,7 +1531,7 @@ layout_with_mds <- function(graph, dist = NULL, dim = 2, # Argument checks ensure_igraph(graph) if (!is.null(dist)) dist <- structure(as.double(dist), dim = dim(dist)) - dim <- as.integer(dim) + dim <- as.numeric(dim) on.exit(.Call(R_igraph_finalizer)) # Function call @@ -1760,7 +1760,7 @@ layout_with_sugiyama <- function(graph, layers = NULL, hgap = 1, vgap = 1, if (!is.null(layers)) layers <- as.numeric(layers) - 1 hgap <- as.numeric(hgap) vgap <- as.numeric(vgap) - maxiter <- as.integer(maxiter) + maxiter <- as.numeric(maxiter) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } diff --git a/R/make.R b/R/make.R index 92e07196250..a877e8a714c 100644 --- a/R/make.R +++ b/R/make.R @@ -704,7 +704,7 @@ make_empty_graph <- function(n = 0, directed = TRUE) { stop("number of vertices must be an integer") } - n <- suppressWarnings(as.integer(n)) + n <- suppressWarnings(as.numeric(n)) if (is.na(n)) { stop("number of vertices must be an integer") } @@ -1334,7 +1334,7 @@ atlas <- function(...) constructor_spec(graph_from_atlas, ...) make_chordal_ring <- function(n, w, directed = FALSE) { on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_extended_chordal_ring, as.integer(n), + R_igraph_extended_chordal_ring, as.numeric(n), as.matrix(w), as.logical(directed) ) if (igraph_opt("add.params")) { @@ -1527,8 +1527,8 @@ kautz_graph <- function(...) constructor_spec(make_kautz_graph, ...) #' @export make_full_bipartite_graph <- function(n1, n2, directed = FALSE, mode = c("all", "out", "in")) { - n1 <- as.integer(n1) - n2 <- as.integer(n2) + n1 <- as.numeric(n1) + n2 <- as.numeric(n2) directed <- as.logical(directed) mode1 <- switch(igraph.match.arg(mode), "out" = 1, @@ -1653,7 +1653,7 @@ bipartite_graph <- function(...) constructor_spec(make_bipartite_graph, ...) #' print_all(make_full_citation_graph(10)) make_full_citation_graph <- function(n, directed = TRUE) { # Argument checks - n <- as.integer(n) + n <- as.numeric(n) directed <- as.logical(directed) on.exit(.Call(R_igraph_finalizer)) diff --git a/R/motifs.R b/R/motifs.R index 65c4eb04de0..019e7327062 100644 --- a/R/motifs.R +++ b/R/motifs.R @@ -63,7 +63,7 @@ motifs <- function(graph, size = 3, cut.prob = rep(0, size)) { on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_motifs_randesu, graph, as.integer(size), + R_igraph_motifs_randesu, graph, as.numeric(size), as.numeric(cut.prob) ) res[is.nan(res)] <- NA @@ -107,7 +107,7 @@ count_motifs <- function(graph, size = 3, cut.prob = rep(0, size)) { on.exit(.Call(R_igraph_finalizer)) .Call( - R_igraph_motifs_randesu_no, graph, as.integer(size), + R_igraph_motifs_randesu_no, graph, as.numeric(size), as.numeric(cut.prob) ) } @@ -156,8 +156,8 @@ sample_motifs <- function(graph, size = 3, cut.prob = rep(0, size), on.exit(.Call(R_igraph_finalizer)) .Call( - R_igraph_motifs_randesu_estimate, graph, as.integer(size), - as.numeric(cut.prob), as.integer(sample.size), as.numeric(sample) + R_igraph_motifs_randesu_estimate, graph, as.numeric(size), + as.numeric(cut.prob), as.numeric(sample.size), as.numeric(sample) ) } diff --git a/R/paths.R b/R/paths.R index 681709bbb88..46929083f77 100644 --- a/R/paths.R +++ b/R/paths.R @@ -74,7 +74,7 @@ all_simple_paths <- function(graph, from, to = V(graph), ## Function call res <- .Call( R_igraph_get_all_simple_paths, graph, from - 1, to - 1, - as.integer(cutoff), mode + as.numeric(cutoff), mode ) res <- get.all.simple.paths.pp(res) @@ -111,11 +111,9 @@ all_simple_paths <- function(graph, from, to = V(graph), #' @export is_dag <- is_dag_impl - #' Acyclic graphs #' #' This function tests whether the given graph is free of cycles. -#' It is only available as of igraph 2.0.0. #' #' This function looks for directed cycles in directed graphs and undirected #' cycles in undirected graphs. @@ -123,7 +121,7 @@ is_dag <- is_dag_impl #' @param graph The input graph. #' @return A logical vector of length one. #' @keywords graphs -#' @examplesIf FALSE +#' @examples #' #' g <- make_graph(c(1,2, 1,3, 2,4, 3,4), directed = TRUE) #' is_acyclic(g) @@ -133,10 +131,7 @@ is_dag <- is_dag_impl #' @family cycles #' @family structural.properties #' @export -#' @keywords internal -is_acyclic <- function(graph) { - cli::cli_abort("Only implemented in igraph 2.0.0") -} +is_acyclic <- is_acyclic_impl #' Maximum cardinality search #' diff --git a/R/plot.R b/R/plot.R index 2d934fedb96..07838d30fb2 100644 --- a/R/plot.R +++ b/R/plot.R @@ -528,7 +528,7 @@ plot.igraph <- function(x, #' #' g <- make_lattice(c(5, 5, 5)) #' coords <- layout_with_fr(g, dim = 3) -#' if (interactive()) { +#' if (interactive() && requireNamespace("rgl", quietly = TRUE)) { #' rglplot(g, layout = coords) #' } #' diff --git a/R/random_walk.R b/R/random_walk.R index 92d0a8e10b4..c7537528d2f 100644 --- a/R/random_walk.R +++ b/R/random_walk.R @@ -52,9 +52,14 @@ random_walk <- function( graph, start, steps, + weights = NULL, mode = c("out", "in", "all", "total"), stuck = c("return", "error")) { - random_walk_impl(graph, start, steps + 1, mode, stuck) + mode <- match.arg(mode) + stuck <- match.arg(stuck) + out <- random_walk_impl(graph, start, steps, weights, mode, stuck) + # FIXME: Support returning the full structure + out$vertices } #' @rdname random_walk diff --git a/R/scan.R b/R/scan.R index 69cddd966ad..7033ac84eac 100644 --- a/R/scan.R +++ b/R/scan.R @@ -115,7 +115,7 @@ local_scan <- function(graph.us, graph.them = NULL, k = 1, FUN = NULL, stopifnot(is.null(graph.them) || vcount(graph.them) == vcount(graph.us)) ## k must be non-negative integer - stopifnot(length(k) == 1, k >= 0, as.integer(k) == k) + stopifnot(length(k) == 1, k >= 0, trunc(k) == k) ## Must be NULL or a function stopifnot(is.null(FUN) || is.function(FUN) || @@ -157,7 +157,7 @@ local_scan <- function(graph.us, graph.them = NULL, k = 1, FUN = NULL, if (!is.null(neighborhoods)) { if (is.character(FUN) && FUN %in% c("ecount", "sumweights")) { neighborhoods <- lapply(neighborhoods, function(x) { - as.integer(x) - 1L + as.numeric(x) - 1 }) on.exit(.Call(R_igraph_finalizer)) .Call( @@ -193,7 +193,7 @@ local_scan <- function(graph.us, graph.them = NULL, k = 1, FUN = NULL, } else if (is.character(FUN) && FUN %in% c("ecount", "sumweights")) { on.exit(.Call(R_igraph_finalizer)) .Call( - R_igraph_local_scan_k_ecount, graph.us, as.integer(k), + R_igraph_local_scan_k_ecount, graph.us, as.numeric(k), if (weighted) as.numeric(E(graph.us)$weight) else NULL, cmode ) @@ -210,7 +210,7 @@ local_scan <- function(graph.us, graph.them = NULL, k = 1, FUN = NULL, neighborhoods <- lapply(neighborhoods, as.vector) if (is.character(FUN) && FUN %in% c("ecount", "wumweights")) { neighborhoods <- lapply(neighborhoods, function(x) { - as.integer(x) - 1L + as.numeric(x) - 1 }) on.exit(.Call(R_igraph_finalizer)) .Call( @@ -249,7 +249,7 @@ local_scan <- function(graph.us, graph.them = NULL, k = 1, FUN = NULL, on.exit(.Call(R_igraph_finalizer)) .Call( R_igraph_local_scan_k_ecount_them, graph.us, graph.them, - as.integer(k), + as.numeric(k), if (weighted) as.numeric(E(graph.them)$weight) else NULL, cmode ) @@ -337,10 +337,10 @@ scan_stat <- function(graphs, tau = 1, ell = 0, ) ## tau must the a non-negative integer - stopifnot(length(tau) == 1, tau >= 0, as.integer(tau) == tau) + stopifnot(length(tau) == 1, tau >= 0, trunc(tau) == tau) ## ell must the a non-negative integer - stopifnot(length(ell) == 1, ell >= 0, as.integer(ell) == ell) + stopifnot(length(ell) == 1, ell >= 0, trunc(ell) == ell) locality <- igraph.match.arg(locality) diff --git a/R/sgm.R b/R/sgm.R index 5fefe38f36d..9dd10a2ef1d 100644 --- a/R/sgm.R +++ b/R/sgm.R @@ -9,7 +9,7 @@ solve_LSAP <- function(x, maximum = FALSE) { if (nc > nr) x <- rbind(x, matrix(2 * sum(x), nc - nr, nc)) if (maximum) x <- max(x) - x storage.mode(x) <- "double" - out <- .Call(R_igraph_solve_lsap, x, as.integer(nc)) + 1L + out <- .Call(R_igraph_solve_lsap, x, as.numeric(nc)) + 1L out[seq_len(nr)] } diff --git a/R/structural.properties.R b/R/structural.properties.R index 6c94eec9e9e..ff4086b6d50 100644 --- a/R/structural.properties.R +++ b/R/structural.properties.R @@ -631,11 +631,11 @@ all_shortest_paths <- function(graph, from, } if (igraph_opt("return.vs.es")) { - res$res <- lapply(res$res, unsafe_create_vs, graph = graph, verts = V(graph)) + res$vpaths <- lapply(res$vpaths, unsafe_create_vs, graph = graph, verts = V(graph)) } # Transitional, eventually, remove $res - res$vpaths <- res$res + res$res <- res$vpaths res } @@ -766,7 +766,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 } @@ -1108,7 +1108,7 @@ ego_size <- function(graph, order = 1, nodes = V(graph), "in" = 2, "all" = 3 ) - mindist <- as.integer(mindist) + mindist <- as.numeric(mindist) on.exit(.Call(R_igraph_finalizer)) .Call( @@ -1217,7 +1217,7 @@ ego <- function(graph, order = 1, nodes = V(graph), "in" = 2, "all" = 3 ) - mindist <- as.integer(mindist) + mindist <- as.numeric(mindist) on.exit(.Call(R_igraph_finalizer)) res <- .Call( @@ -1244,17 +1244,17 @@ make_ego_graph <- function(graph, order = 1, nodes = V(graph), ensure_igraph(graph) mode <- igraph.match.arg(mode) mode <- switch(mode, - "out" = 1, - "in" = 2, - "all" = 3 + "out" = 1L, + "in" = 2L, + "all" = 3L ) - mindist <- as.integer(mindist) + mindist <- as.numeric(mindist) on.exit(.Call(R_igraph_finalizer)) res <- .Call( R_igraph_neighborhood_graphs, graph, as_igraph_vs(graph, nodes) - 1, as.numeric(order), - as.numeric(mode), mindist + as.integer(mode), mindist ) res } @@ -1951,7 +1951,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 fac4e3fbee9..a8e470bc049 100644 --- a/R/topology.R +++ b/R/topology.R @@ -157,9 +157,9 @@ graph.subisomorphic.lad <- function(pattern, target, domains = NULL, ensure_igraph(target) induced <- as.logical(induced) if (time.limit == Inf) { - time.limit <- 0L + time.limit <- 0 } else { - time.limit <- as.integer(time.limit) + time.limit <- as.numeric(time.limit) } map <- as.logical(map) all.maps <- as.logical(all.maps) @@ -310,7 +310,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") { @@ -319,7 +319,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/R/trees.R b/R/trees.R index ef8d8d84759..239b48af47d 100644 --- a/R/trees.R +++ b/R/trees.R @@ -72,7 +72,7 @@ is_tree <- function(graph, mode = c("out", "in", "all", "total"), details = FALS #' the graph is not a tree.} #' #' @keywords graphs -#' @examplesIf FALSE +#' @examples #' #' g <- make_tree(3) + make_tree(5,3) #' is_forest(g) @@ -80,10 +80,7 @@ is_tree <- function(graph, mode = c("out", "in", "all", "total"), details = FALS #' #' @family trees #' @export -#' @keywords internal -is_forest <- function(graph, mode, details) { - cli::cli_abort("Only implemented in igraph 2.0.0") -} +is_forest <- is_forest_impl #' Convert a tree graph to its Prüfer sequence #' diff --git a/cigraph b/cigraph deleted file mode 160000 index 58e14610c5a..00000000000 --- a/cigraph +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 58e14610c5af44cc1ca222090354a0b327af32f1 diff --git a/cleanup b/cleanup index 50528cde712..d1fa70481a3 100755 --- a/cleanup +++ b/cleanup @@ -1,8 +1,5 @@ #! /bin/sh -rm -f src/config.h src/Makevars -touch src/config.h - # Object files cause problems on Github Actions where they get included # in the source package that is re-generated from the original source, so # we remove them here in the cleanup step diff --git a/cleanup.win b/cleanup.win index 50528cde712..d1fa70481a3 100644 --- a/cleanup.win +++ b/cleanup.win @@ -1,8 +1,5 @@ #! /bin/sh -rm -f src/config.h src/Makevars -touch src/config.h - # Object files cause problems on Github Actions where they get included # in the source package that is re-generated from the original source, so # we remove them here in the cleanup step diff --git a/configure b/configure index 2e5d6484602..5f424c09d89 100755 --- a/configure +++ b/configure @@ -1,6439 +1,27 @@ -#! /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. ## -## -------------------- ## +#!/bin/bash -# 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." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - 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' +# Use pkg-config or xml2-config to get the include directory for libxml-2.0 +xml2_include_dir="" +if which xml2-config >/dev/null 2>&1; then + xml2_include_dir=$(xml2-config --cflags | sed 's/^-I//') +elif which pkg-config >/dev/null 2>&1; then + xml2_include_dir=$(pkg-config --cflags libxml-2.0 | sed 's/^-I//') else - ac_cs_awk_cr=$ac_cr + echo "Error: Neither xml2-config nor pkg-config is available" + exit 1 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" +if [[ -n "$xml2_include_dir" ]]; then + PKG_CFLAGS="-I$xml2_include_dir" + echo "libxml2 include directory: $xml2_include_dir" 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/^[^=]*=[ ]*$// -}' + echo "Error: libxml2 include directory not found" + exit 1 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 +echo "# Generated from Makevars.in, do not edit by hand" > src/Makevars.new +sed -e "s|@cflags@|$PKG_CFLAGS|" src/Makevars.in >> src/Makevars.new +if [ ! -f src/Makevars ] || (which diff > /dev/null && ! diff -q src/Makevars src/Makevars.new); then + cp -f src/Makevars.new src/Makevars 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;} -fi - - -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}" - +rm -f src/Makevars.new 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/man/assortativity.Rd b/man/assortativity.Rd index a1e83a6693f..c89f25c6a37 100644 --- a/man/assortativity.Rd +++ b/man/assortativity.Rd @@ -14,11 +14,12 @@ assortativity( ..., values.in = NULL, directed = TRUE, + normalized = TRUE, types1 = NULL, types2 = NULL ) -assortativity_nominal(graph, types, directed = TRUE) +assortativity_nominal(graph, types, directed = TRUE, normalized = TRUE) assortativity_degree(graph, directed = TRUE) } @@ -45,6 +46,8 @@ Supply measure for directed graphs and the undirected version for undirected graphs.} +\item{normalized}{TBD} + \item{types1, types2}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Deprecated aliases for \code{values} and \code{values.in}, respectively.} diff --git a/man/automorphism_group.Rd b/man/automorphism_group.Rd index 1def2b4d48a..ce0015292d2 100644 --- a/man/automorphism_group.Rd +++ b/man/automorphism_group.Rd @@ -6,7 +6,7 @@ \usage{ automorphism_group( graph, - colors, + colors = NULL, sh = c("fm", "f", "fs", "fl", "flm", "fsm"), details = FALSE ) diff --git a/man/canonical_permutation.Rd b/man/canonical_permutation.Rd index 8d714e09918..0edecfdb432 100644 --- a/man/canonical_permutation.Rd +++ b/man/canonical_permutation.Rd @@ -7,7 +7,7 @@ \usage{ canonical_permutation( graph, - colors, + colors = NULL, sh = c("fm", "f", "fs", "fl", "flm", "fsm") ) } diff --git a/man/cluster_label_prop.Rd b/man/cluster_label_prop.Rd index 3f7280f7f91..918d11b3784 100644 --- a/man/cluster_label_prop.Rd +++ b/man/cluster_label_prop.Rd @@ -5,10 +5,20 @@ \alias{label.propagation.community} \title{Finding communities based on propagating labels} \usage{ -cluster_label_prop(graph, weights = NULL, ..., initial = NULL, fixed = NULL) +cluster_label_prop( + graph, + weights = NULL, + ..., + mode = c("out", "in", "all"), + initial = NULL, + fixed = NULL +) } \arguments{ -\item{graph}{The input graph, should be undirected to make sense.} +\item{graph}{The input graph. Note that the algorithm wsa originally +defined for undirected graphs. You are advised to set \sQuote{mode} to +\code{all} if you pass a directed graph here to treat it as +undirected.} \item{weights}{The weights of the edges. It must be a positive numeric vector, \code{NULL} or \code{NA}. If it is \code{NULL} and the input graph has a diff --git a/man/count_automorphisms.Rd b/man/count_automorphisms.Rd index f980a2d8fea..ac60805e999 100644 --- a/man/count_automorphisms.Rd +++ b/man/count_automorphisms.Rd @@ -6,7 +6,11 @@ \alias{automorphisms} \title{Number of automorphisms} \usage{ -count_automorphisms(graph, colors, sh = c("fm", "f", "fs", "fl", "flm", "fsm")) +count_automorphisms( + graph, + colors = NULL, + sh = c("fm", "f", "fs", "fl", "flm", "fsm") +) } \arguments{ \item{graph}{The input graph, it is treated as undirected.} diff --git a/man/greedy_vertex_coloring.Rd b/man/greedy_vertex_coloring.Rd index c2c29ed5b8a..027c3faaadf 100644 --- a/man/greedy_vertex_coloring.Rd +++ b/man/greedy_vertex_coloring.Rd @@ -4,7 +4,7 @@ \alias{greedy_vertex_coloring} \title{Greedy vertex coloring} \usage{ -greedy_vertex_coloring(graph, heuristic = c("colored_neighbors")) +greedy_vertex_coloring(graph, heuristic = c("colored_neighbors", "dsatur")) } \arguments{ \item{graph}{The graph object to color} diff --git a/man/igraph_demo.Rd b/man/igraph_demo.Rd index 652add7f60d..f64ce1b84ee 100644 --- a/man/igraph_demo.Rd +++ b/man/igraph_demo.Rd @@ -29,7 +29,7 @@ The \code{tcltk} package is needed for \code{igraph_demo()}. \examples{ igraph_demo() -if (interactive()) { +if (interactive() && requireNamespace("tcltk", quietly = TRUE)) { igraph_demo("centrality") } diff --git a/man/is_acyclic.Rd b/man/is_acyclic.Rd index 8330b21dbf9..80137d0e8b6 100644 --- a/man/is_acyclic.Rd +++ b/man/is_acyclic.Rd @@ -14,19 +14,16 @@ A logical vector of length one. } \description{ This function tests whether the given graph is free of cycles. -It is only available as of igraph 2.0.0. } \details{ This function looks for directed cycles in directed graphs and undirected cycles in undirected graphs. } \examples{ -\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} g <- make_graph(c(1,2, 1,3, 2,4, 3,4), directed = TRUE) is_acyclic(g) is_acyclic(as.undirected(g)) -\dontshow{\}) # examplesIf} } \seealso{ \code{\link[=is_forest]{is_forest()}} and \code{\link[=is_dag]{is_dag()}} for functions specific to undirected @@ -66,4 +63,3 @@ Other structural.properties: \concept{cycles} \concept{structural.properties} \keyword{graphs} -\keyword{internal} diff --git a/man/is_forest.Rd b/man/is_forest.Rd index 2092799f5b5..eeb7acdd549 100644 --- a/man/is_forest.Rd +++ b/man/is_forest.Rd @@ -4,7 +4,7 @@ \alias{is_forest} \title{Decide whether a graph is a forest.} \usage{ -is_forest(graph, mode, details) +is_forest(graph, mode = c("out", "in", "all", "total"), details = FALSE) } \arguments{ \item{graph}{An igraph graph object} @@ -39,12 +39,11 @@ By convention, the null graph (i.e. the graph with no vertices) is considered to be a forest. } \examples{ -\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} g <- make_tree(3) + make_tree(5,3) is_forest(g) is_forest(g, details = TRUE) -\dontshow{\}) # examplesIf} + } \seealso{ Other trees: @@ -55,4 +54,3 @@ Other trees: } \concept{trees} \keyword{graphs} -\keyword{internal} diff --git a/man/layout_on_grid.Rd b/man/layout_on_grid.Rd index 6f14eb395b6..ab42c3c27cc 100644 --- a/man/layout_on_grid.Rd +++ b/man/layout_on_grid.Rd @@ -50,7 +50,7 @@ g2 <- make_lattice(c(3, 3, 3)) layout_on_grid(g2, dim = 3) plot(g, layout = layout_on_grid) -if (interactive()) { +if (interactive() && requireNamespace("rgl", quietly = TRUE)) { rglplot(g, layout = layout_on_grid(g, dim = 3)) } } diff --git a/man/random_walk.Rd b/man/random_walk.Rd index 139d1296ae9..9c22681f9b9 100644 --- a/man/random_walk.Rd +++ b/man/random_walk.Rd @@ -9,6 +9,7 @@ random_walk( graph, start, steps, + weights = NULL, mode = c("out", "in", "all", "total"), stuck = c("return", "error") ) @@ -29,19 +30,19 @@ random_edge_walk( \item{steps}{The number of steps to make.} -\item{mode}{How to follow directed edges. \code{"out"} steps along the -edge direction, \code{"in"} is opposite to that. \code{"all"} ignores -edge directions. This argument is ignored for undirected graphs.} - -\item{stuck}{What to do if the random walk gets stuck. \code{"return"} -returns the partial walk, \code{"error"} raises an error.} - \item{weights}{The edge weights. Larger edge weights increase the probability that an edge is selected by the random walker. In other words, larger edge weights correspond to stronger connections. The \sQuote{weight} edge attribute is used if present. Supply \sQuote{\code{NA}} here if you want to ignore the \sQuote{weight} edge attribute.} + +\item{mode}{How to follow directed edges. \code{"out"} steps along the +edge direction, \code{"in"} is opposite to that. \code{"all"} ignores +edge directions. This argument is ignored for undirected graphs.} + +\item{stuck}{What to do if the random walk gets stuck. \code{"return"} +returns the partial walk, \code{"error"} raises an error.} } \value{ For \code{random_walk()}, a vertex sequence of length \code{steps + 1} diff --git a/man/rglplot.Rd b/man/rglplot.Rd index 10ddb814836..88537ef8ca5 100644 --- a/man/rglplot.Rd +++ b/man/rglplot.Rd @@ -30,7 +30,7 @@ arguments. g <- make_lattice(c(5, 5, 5)) coords <- layout_with_fr(g, dim = 3) -if (interactive()) { +if (interactive() && requireNamespace("rgl", quietly = TRUE)) { rglplot(g, layout = coords) } diff --git a/man/which_mutual.Rd b/man/which_mutual.Rd index 866184c56e9..a0188b7dc9e 100644 --- a/man/which_mutual.Rd +++ b/man/which_mutual.Rd @@ -5,7 +5,7 @@ \alias{is.mutual} \title{Find mutual edges in a directed graph} \usage{ -which_mutual(graph, eids = E(graph)) +which_mutual(graph, eids = E(graph), loops = TRUE) } \arguments{ \item{graph}{The input graph.} diff --git a/rconfigure.py b/rconfigure.py new file mode 100644 index 00000000000..baea369c486 --- /dev/null +++ b/rconfigure.py @@ -0,0 +1,33 @@ +import os +import sys + +def open_utf8(fpath, flags): + if sys.version_info[0] < 3: + return open(fpath, flags) + else: + return open(fpath, flags, encoding="utf8") + +ignore_folders = [ + "src/vendor/cigraph/vendor/glpk", + "src/vendor/cigraph/vendor/lapack", + "src/vendor/cigraph/vendor/mini-gmp", + "src/vendor/cigraph/vendor/f2c", + "src/vendor/cigraph/etc" +] + +sources = [] +for root, dirnames, filenames in os.walk('src'): + for filename in filenames: + if filename.endswith(('.c', '.cc', '.cpp', '.f')): + ignore_file = False + for f in ignore_folders: + if root.startswith(f): + ignore_file = True + if ignore_file: + continue + sources.append(os.path.join(root[4:], filename[:filename.rfind('.')] + '.o')) + +text = "SOURCES=" + ' '.join(sources) + '\n' + +with open_utf8(os.path.join('src', 'sources.mk'), 'w') as f: + f.write(text) diff --git a/revdep/README.md b/revdep/README.md index cb6b4b42840..eb0f63d45e6 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,33 +1,26 @@ # Revdeps -## New problems (2) - -|package |version |error |warning |note | -|:-----------|:-------|:------|:-------|:----| -|[influential](problems.md#influential)|2.2.8 | |__+2__ | | -|[statGraph](problems.md#statgraph)|0.5.0 |__+1__ | | | - -## All (19) +## New problems (19) |package |version |error |warning |note | |:-----------------|:-------|:------|:-------|:----| -|[causaleffect](problems.md#causaleffect)|1.3.15 | |1 | | -|centiserve |1.0.0 | | | | -|cfid |0.1.7 | | | | -|[CINNA](problems.md#cinna)|1.2.2 | | |1 | -|[dosearch](problems.md#dosearch)|1.0.8 | | |2 | -|fanovaGraph |1.5 | | | | -|[ggnetwork](problems.md#ggnetwork)|0.5.12 | | |1 | -|[inferCSN](problems.md#infercsn)|0.99.8 | | |1 | +|[Canek](problems.md#canek)|0.2.4 |__+1__ | | | +|[countland](problems.md#countland)|0.1.1 |__+1__ | | | +|[DiagrammeR](problems.md#diagrammer)|1.0.10 |__+1__ | |1 | +|[ggnetwork](problems.md#ggnetwork)|0.5.12 |__+1__ | |1 | +|[inferCSN](problems.md#infercsn)|0.99.8 |__+1__ | |1 | |[influential](problems.md#influential)|2.2.8 | |__+2__ | | -|intergraph |2.0-3 | | | | -|[markovchain](problems.md#markovchain)|0.9.5 |1 | |3 | -|nosoi |1.1.0 | | | | -|[pcalg](problems.md#pcalg)|2.7-9 | | |3 | -|[phyloseqGraphTest](problems.md#phyloseqgraphtest)|0.1.0 | | |2 | -|rgraph6 |2.0-2 | | | | -|riverconn |0.3.28 | | | | -|[shazam](problems.md#shazam)|1.2.0 | |1 | | +|[manynet](problems.md#manynet)|0.2.8 |__+1__ | |2 | +|[migraph](problems.md#migraph)|1.1.5 |__+1__ | | | +|[molnet](problems.md#molnet)|0.1.0 |__+1__ | | | +|[NAIR](problems.md#nair)|1.0.2 |__+1__ | |1 | +|[nat](problems.md#nat)|1.8.23 |__+1__ | | | +|[netcom](problems.md#netcom)|2.1.6 |__+2__ | |1 | +|[nosoi](problems.md#nosoi)|1.1.0 |__+1__ | | | +|[oddnet](problems.md#oddnet)|0.1.0 |__+1__ | | | +|[pcalg](problems.md#pcalg)|2.7-9 |__+1__ | |3 | +|[phyloseqGraphTest](problems.md#phyloseqgraphtest)|0.1.0 |__+2__ | |2 | +|[rgraph6](problems.md#rgraph6)|2.0-2 |__+1__ | | | +|[riverconn](problems.md#riverconn)|0.3.28 |__+1__ | | | |[statGraph](problems.md#statgraph)|0.5.0 |__+1__ | | | -|TreeDimensionTest |0.0.2 | | | | diff --git a/revdep/cran.md b/revdep/cran.md index c79f89cee11..a8dc7684367 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,8 +1,8 @@ ## revdepcheck results -We checked 19 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 21 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. - * We saw 2 new problems + * We saw 19 new problems * We failed to check 0 packages Issues with CRAN packages are summarised below. @@ -10,10 +10,63 @@ Issues with CRAN packages are summarised below. ### New problems (This reports the first line of each new failure) +* Canek + checking tests ... ERROR + +* countland + checking tests ... ERROR + +* DiagrammeR + checking tests ... ERROR + +* ggnetwork + checking tests ... ERROR + +* inferCSN + checking examples ... ERROR + * influential checking dependencies in R code ... WARNING checking for code/documentation mismatches ... WARNING +* manynet + checking tests ... ERROR + +* migraph + checking examples ... ERROR + +* molnet + checking examples ... ERROR + +* NAIR + checking tests ... ERROR + +* nat + checking tests ... ERROR + +* netcom + checking examples ... ERROR + checking re-building of vignette outputs ... ERROR + +* nosoi + checking re-building of vignette outputs ... ERROR + +* oddnet + checking examples ... ERROR + +* pcalg + checking tests ... ERROR + +* phyloseqGraphTest + checking examples ... ERROR + checking re-building of vignette outputs ... ERROR + +* rgraph6 + checking re-building of vignette outputs ... ERROR + +* riverconn + checking re-building of vignette outputs ... ERROR + * statGraph checking examples ... ERROR diff --git a/revdep/problems.md b/revdep/problems.md index 23c94a5da83..597e6241aa5 100644 --- a/revdep/problems.md +++ b/revdep/problems.md @@ -1,93 +1,131 @@ -# causaleffect +# Canek
-* Version: 1.3.15 -* GitHub: https://github.com/santikka/causaleffect -* Source code: https://github.com/cran/causaleffect -* Date/Publication: 2022-07-14 09:10:05 UTC -* Number of recursive dependencies: 17 +* Version: 0.2.4 +* GitHub: https://github.com/MartinLoza/Canek +* Source code: https://github.com/cran/Canek +* Date/Publication: 2023-11-06 00:10:02 UTC +* Number of recursive dependencies: 222 -Run `revdepcheck::cloud_details(, "causaleffect")` for more info +Run `revdepcheck::cloud_details(, "Canek")` for more info
-## In both +## Newly broken -* checking re-building of vignette outputs ... WARNING - ``` - Error(s) in re-building vignettes: - --- re-building ‘causaleffect.ltx’ using tex - Error: processing vignette 'causaleffect.ltx' failed with diagnostics: - Running 'texi2dvi' on 'causaleffect.ltx' failed. - LaTeX errors: - ! LaTeX Error: File `thumbpdf.sty' not found. - - Type X to quit or to proceed, - or enter new name. (Default extension: sty) - +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > library(Canek) + > + > test_check("Canek") + [ FAIL 2 | WARN 3 | SKIP 0 | PASS 90 ] + + ══ Failed tests ════════════════════════════════════════════════════════════════ ... - l.16 \usepackage - {csquotes}^^M - ! ==> Fatal error occurred, no output PDF file produced! - --- failed re-building ‘simplification.ltx’ - - SUMMARY: processing the following files failed: - ‘causaleffect.ltx’ ‘simplification.ltx’ - - Error: Vignette re-building failed. - Execution halted + as.integer(table(dataLouvain$cluster)) not equal to c(96, 125, 140, 171, 99). + Lengths differ: 4 is not 5 + ── Failure ('test-Clustering.R:20:3'): Clustering with louvain works ─────────── + dim(dataLouvain$centers) not equal to c(5, 10). + 1/2 mismatches + [1] 4 - 5 == -1 + + [ FAIL 2 | WARN 3 | SKIP 0 | PASS 90 ] + Error: Test failures + Execution halted ``` -# CINNA +# countland
-* Version: 1.2.2 +* Version: 0.1.1 * GitHub: NA -* Source code: https://github.com/cran/CINNA -* Date/Publication: 2023-08-08 16:40:02 UTC -* Number of recursive dependencies: 149 +* Source code: https://github.com/cran/countland +* Date/Publication: 2022-08-17 06:40:06 UTC +* Number of recursive dependencies: 199 -Run `revdepcheck::cloud_details(, "CINNA")` for more info +Run `revdepcheck::cloud_details(, "countland")` for more info
-## In both +## Newly broken -* checking dependencies in R code ... NOTE - ``` - Namespaces in Imports field not imported from: - ‘circlize’ ‘utils’ - All declared Imports should be used. +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > library(countland) + > + > test_check("countland") + countland object + the count matrix has 1000 genes (rows) + and 100 cells (columns) + ... + 2. ├─methods::as(...) + 3. │ └─methods:::.class1(object) + 4. ├─base::do.call(...) + 5. └─base::lapply(...) + 6. └─countland (local) FUN(X[[i]], ...) + 7. └─base::apply(combX[spectral_cluster$cluster == x, ], 2, sum) + + [ FAIL 4 | WARN 0 | SKIP 0 | PASS 61 ] + Error: Test failures + Execution halted ``` -# dosearch +# DiagrammeR
-* Version: 1.0.8 -* GitHub: NA -* Source code: https://github.com/cran/dosearch -* Date/Publication: 2021-08-19 16:40:02 UTC -* Number of recursive dependencies: 18 +* Version: 1.0.10 +* GitHub: https://github.com/rich-iannone/DiagrammeR +* Source code: https://github.com/cran/DiagrammeR +* Date/Publication: 2023-05-18 14:30:07 UTC +* Number of recursive dependencies: 100 -Run `revdepcheck::cloud_details(, "dosearch")` for more info +Run `revdepcheck::cloud_details(, "DiagrammeR")` for more info
-## In both +## Newly broken -* checking C++ specification ... NOTE - ``` - Specified C++11: please drop specification unless essential +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > library(DiagrammeR) + > + > suppressWarnings(RNGversion("3.5.0")) + > test_check("DiagrammeR") + [ FAIL 2 | WARN 12 | SKIP 0 | PASS 2128 ] + + ... + 1/1 mismatches + [1] 107 - 98 == 9 + ── Failure ('test-count_entities.R:142:3'): counting the number of strongly connected components is possible ── + graph %>% count_s_connected_cmpts() not equal to 4. + 1/1 mismatches + [1] 2 - 4 == -2 + + [ FAIL 2 | WARN 12 | SKIP 0 | PASS 2128 ] + Error: Test failures + Execution halted ``` -* checking installed package size ... NOTE +## In both + +* checking data for non-ASCII characters ... NOTE ``` - installed size is 6.5Mb - sub-directories of 1Mb or more: - libs 6.2Mb + Note: found 1 marked UTF-8 string ``` # ggnetwork @@ -104,6 +142,33 @@ Run `revdepcheck::cloud_details(, "ggnetwork")` for more info +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > library(ggnetwork) + Loading required package: ggplot2 + > + > test_check("ggnetwork") + [ FAIL 1 | WARN 0 | SKIP 0 | PASS 38 ] + + ... + ▆ + 1. ├─testthat::expect_s3_class(...) at test-ggnetwork.R:35:3 + 2. │ └─testthat::quasi_label(enquo(object), arg = "object") + 3. │ └─rlang::eval_bare(expr, quo_get_env(quo)) + 4. └─ggnetwork::ggnetwork(n, layout = matrix(runif(28), ncol = 2)) at test-ggnetwork.R:36:5 + 5. └─ggnetwork:::fortify.igraph(x, ...) + + [ FAIL 1 | WARN 0 | SKIP 0 | PASS 38 ] + Error: Test failures + Execution halted + ``` + ## In both * checking dependencies in R code ... NOTE @@ -127,6 +192,29 @@ Run `revdepcheck::cloud_details(, "inferCSN")` for more info +## Newly broken + +* checking examples ... ERROR + ``` + Running examples in ‘inferCSN-Ex.R’ failed + The error most likely occurred in: + + > ### Name: dynamic.networks + > ### Title: Plot of dynamic networks + > ### Aliases: dynamic.networks + > + > ### ** Examples + > + > library(inferCSN) + > data("exampleMatrix") + > weightDT <- inferCSN(exampleMatrix) + > g <- dynamic.networks(weightDT, regulators = weightDT[1, 1]) + Error in fortify.igraph(x, ...) : + layout matrix dimensions do not match network size + Calls: dynamic.networks -> ggnetwork -> fortify.igraph + Execution halted + ``` + ## In both * checking installed package size ... NOTE @@ -173,62 +261,374 @@ Run `revdepcheck::cloud_details(, "influential")` for more info Position: 1 Code: ... Docs: incidence ``` -# markovchain +# manynet
-* Version: 0.9.5 -* GitHub: https://github.com/spedygiorgio/markovchain -* Source code: https://github.com/cran/markovchain -* Date/Publication: 2023-09-24 09:20:02 UTC -* Number of recursive dependencies: 105 +* Version: 0.2.8 +* GitHub: https://github.com/snlab-ch/manynet +* Source code: https://github.com/cran/manynet +* Date/Publication: 2023-11-02 10:10:08 UTC +* Number of recursive dependencies: 138 + +Run `revdepcheck::cloud_details(, "manynet")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > library(manynet) + Registered S3 method overwritten by 'manynet': + method from + print.tbl_graph tidygraph + > + > test_check("manynet") + ... + + ══ Failed tests ════════════════════════════════════════════════════════════════ + ── Failure ('test-make_create.R:40:3'): tree creation works ──────────────────── + unname(as_matrix(create_tree(c(2, 2)))) not equal to matrix(c(1, 1, 1, 0), 2, 2). + 1/4 mismatches + [1] 0 - 1 == -1 + + [ FAIL 1 | WARN 2 | SKIP 10 | PASS 303 ] + Error: Test failures + Execution halted + ``` + +## In both + +* checking package dependencies ... NOTE + ``` + Package which this enhances but not available for checking: ‘Rgraphviz’ + ``` + +* checking data for non-ASCII characters ... NOTE + ``` + Note: found 7 marked UTF-8 strings + ``` + +# migraph -Run `revdepcheck::cloud_details(, "markovchain")` for more info +
+ +* Version: 1.1.5 +* GitHub: https://github.com/snlab-ch/migraph +* Source code: https://github.com/cran/migraph +* Date/Publication: 2023-11-02 10:10:02 UTC +* Number of recursive dependencies: 116 + +Run `revdepcheck::cloud_details(, "migraph")` for more info
+## Newly broken + +* checking examples ... ERROR + ``` + Running examples in ‘migraph-Ex.R’ failed + The error most likely occurred in: + + > ### Name: features + > ### Title: Measures of network topological features + > ### Aliases: features network_core network_richclub network_factions + > ### network_modularity network_smallworld network_scalefree + > ### network_balance + > + > ### ** Examples + ... + [1] -0.458 + > network_smallworld(ison_brandes) + [1] NaN + > network_smallworld(ison_southern_women) + [1] -1.03 + > network_scalefree(ison_adolescents) + Error in if (out$KS.p < 0.05) cat(paste("Note: Kolgomorov-Smirnov test that data", : + argument is of length zero + Calls: network_scalefree + Execution halted + ``` + +# molnet + +
+ +* Version: 0.1.0 +* GitHub: NA +* Source code: https://github.com/cran/molnet +* Date/Publication: 2021-08-06 08:30:02 UTC +* Number of recursive dependencies: 124 + +Run `revdepcheck::cloud_details(, "molnet")` for more info + +
+ +## Newly broken + +* checking examples ... ERROR + ``` + Running examples in ‘molnet-Ex.R’ failed + The error most likely occurred in: + + > ### Name: graph_metrics + > ### Title: Analyses metrics of an iGraph object + > ### Aliases: graph_metrics + > + > ### ** Examples + > + > adj_mat <- matrix(rnorm(36),nrow=6) + > graph <- igraph::graph_from_adjacency_matrix(adj_mat) + Error in graph.adjacency.dense(adjmatrix, mode = mode, weighted = weighted, : + At vendor/cigraph/src/constructors/adjacency.c:329 : Edge counts should be non-negative, found -2.2147. Invalid value + Calls: -> graph.adjacency.dense + Execution halted + ``` + +# NAIR + +
+ +* Version: 1.0.2 +* GitHub: https://github.com/mlizhangx/Network-Analysis-for-Repertoire-Sequencing- +* Source code: https://github.com/cran/NAIR +* Date/Publication: 2023-09-27 10:20:08 UTC +* Number of recursive dependencies: 87 + +Run `revdepcheck::cloud_details(, "NAIR")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘testthat.R’ + Running the tests in ‘tests/testthat.R’ failed. + Complete output: + > library(testthat) + > library(NAIR) + Welcome to NAIR: Network Analysis of Immune Repertoire. + Get started using `vignette("NAIR")`, or by visiting + https://mlizhangx.github.io/Network-Analysis-for-Repertoire-Sequencing-/ + > + > test_check("NAIR") + ... + ══ Failed tests ════════════════════════════════════════════════════════════════ + ── Failure ('test_functions.R:722:3'): addClusterMembership works ────────────── + net$details$clusters_in_network (`actual`) not equal to c(fast_greedy = 20, leiden = 55) (`expected`). + + `actual`: 20 53 + `expected`: 20 55 + + [ FAIL 1 | WARN 0 | SKIP 0 | PASS 1219 ] + Error: Test failures + Execution halted + ``` + ## In both +* checking installed package size ... NOTE + ``` + installed size is 8.1Mb + sub-directories of 1Mb or more: + libs 6.6Mb + ``` + +# nat + +
+ +* Version: 1.8.23 +* GitHub: https://github.com/natverse/nat +* Source code: https://github.com/cran/nat +* Date/Publication: 2023-08-25 15:40:02 UTC +* Number of recursive dependencies: 92 + +Run `revdepcheck::cloud_details(, "nat")` for more info + +
+ +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘test-all.R’ + Running the tests in ‘tests/test-all.R’ failed. + Complete output: + > library(testthat) + > library(nat) + Loading required package: rgl + Registered S3 method overwritten by 'nat': + method from + as.mesh3d.ashape3d rgl + Some nat functions depend on a CMTK installation. See ?cmtk and README.md for details. + ... + 2. │ └─testthat::quasi_label(enquo(object), label, arg = "object") + 3. │ └─rlang::eval_bare(expr, quo_get_env(quo)) + 4. ├─base::subset(n, n_graph_dfs$order, invert = T) + 5. └─nat:::subset.neuron(n, n_graph_dfs$order, invert = T) + 6. └─nat::prune_vertices(x, r, invert = !invert, ...) + 7. └─igraph::delete.vertices(g, verticestoprune) + + [ FAIL 1 | WARN 0 | SKIP 5 | PASS 787 ] + Error: Test failures + Execution halted + ``` + +# netcom + +
+ +* Version: 2.1.6 +* GitHub: https://github.com/langendorfr/netcom +* Source code: https://github.com/cran/netcom +* Date/Publication: 2022-07-21 17:40:06 UTC +* Number of recursive dependencies: 105 + +Run `revdepcheck::cloud_details(, "netcom")` for more info + +
+ +## Newly broken + +* checking examples ... ERROR + ``` + Running examples in ‘netcom-Ex.R’ failed + The error most likely occurred in: + + > ### Name: best_fit_optim + > ### Title: Empirical parameterization + > ### Aliases: best_fit_optim + > + > ### ** Examples + > + > # Import netcom + ... + + "clustering_coefficient", "page_rank", "communities" + + ), + + DD_weight = 1, + + max_norm = FALSE, + + verbose = FALSE + + ) + Error in igraph::transitivity(igraph_graph, type = "weighted") : + At vendor/cigraph/src/properties/triangles.c:885 : Barrat's weighted transitivity measure works only if the graph has no multi-edges. Invalid value + Calls: best_fit_optim -> compare_Target -> + Execution halted + ``` + * checking re-building of vignette outputs ... ERROR ``` Error(s) in re-building vignettes: ... - --- re-building ‘an_introduction_to_markovchain_package.Rmd’ using rmarkdown - Error: processing vignette 'an_introduction_to_markovchain_package.Rmd' failed with diagnostics: - pandoc version 2.7 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available). - --- failed re-building ‘an_introduction_to_markovchain_package.Rmd’ + --- re-building ‘tutorial.Rmd’ using rmarkdown - --- re-building ‘gsoc_2017_additions.Rmd’ using rmarkdown - --- finished re-building ‘gsoc_2017_additions.Rmd’ + Quitting from lines 200-215 [Classify networks] (tutorial.Rmd) + Error: processing vignette 'tutorial.Rmd' failed with diagnostics: + At vendor/cigraph/src/properties/triangles.c:885 : Barrat's weighted transitivity measure works only if the graph has no multi-edges. Invalid value + --- failed re-building ‘tutorial.Rmd’ - ... - Error: processing vignette 'higher_order_markov_chains.Rmd' failed with diagnostics: - pandoc version 2.7 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available). - --- failed re-building ‘higher_order_markov_chains.Rmd’ - - SUMMARY: processing the following files failed: - ‘an_introduction_to_markovchain_package.Rmd’ - ‘higher_order_markov_chains.Rmd’ + SUMMARY: processing the following file failed: + ‘tutorial.Rmd’ Error: Vignette re-building failed. Execution halted ``` -* checking package dependencies ... NOTE +## In both + +* checking dependencies in R code ... NOTE ``` - Package which this enhances but not available for checking: ‘etm’ + Namespaces in Imports field not imported from: + ‘ggfortify’ ‘ggplot2’ ‘ggraph’ ‘reshape2’ + All declared Imports should be used. ``` -* checking installed package size ... NOTE +# nosoi + +
+ +* Version: 1.1.0 +* GitHub: https://github.com/slequime/nosoi +* Source code: https://github.com/cran/nosoi +* Date/Publication: 2021-08-17 16:20:02 UTC +* Number of recursive dependencies: 147 + +Run `revdepcheck::cloud_details(, "nosoi")` for more info + +
+ +## Newly broken + +* checking re-building of vignette outputs ... ERROR ``` - installed size is 24.0Mb - sub-directories of 1Mb or more: - libs 21.9Mb + Error(s) in re-building vignettes: + --- re-building ‘continuous.Rmd’ using rmarkdown + --- finished re-building ‘continuous.Rmd’ + + --- re-building ‘discrete.Rmd’ using rmarkdown + + Quitting from lines 49-83 [setupMatrix] (discrete.Rmd) + Error: processing vignette 'discrete.Rmd' failed with diagnostics: + layout matrix dimensions do not match network size + --- failed re-building ‘discrete.Rmd’ + ... + --- failed re-building ‘nosoi.Rmd’ + + --- re-building ‘output.Rmd’ using rmarkdown + --- finished re-building ‘output.Rmd’ + + SUMMARY: processing the following files failed: + ‘discrete.Rmd’ ‘nosoi.Rmd’ + + Error: Vignette re-building failed. + Execution halted ``` -* checking for GNU extensions in Makefiles ... NOTE +# oddnet + +
+ +* Version: 0.1.0 +* GitHub: NA +* Source code: https://github.com/cran/oddnet +* Date/Publication: 2022-12-22 20:10:01 UTC +* Number of recursive dependencies: 85 + +Run `revdepcheck::cloud_details(, "oddnet")` for more info + +
+ +## Newly broken + +* checking examples ... ERROR ``` - GNU make is a SystemRequirements. + Running examples in ‘oddnet-Ex.R’ failed + The error most likely occurred in: + + > ### Name: tensorsplat + > ### Title: Implements Danai Koutra's TensorSplat algorithm + > ### Aliases: tensorsplat + > + > ### ** Examples + > + > # We generate a series of networks and add an anomaly at 50th network. + ... + > networks <- list() + > p.or.m.seq <- rep(0.05, 50) + > p.or.m.seq[20] <- 0.2 # anomalous network at 20 + > for(i in 1:100){ + + gr <- igraph::erdos.renyi.game(100, p.or.m = p.or.m.seq[i]) + + networks[[i]] <- igraph::as_adjacency_matrix(gr) + + } + Error in igraph::erdos.renyi.game(100, p.or.m = p.or.m.seq[i]) : + At vendor/cigraph/src/math/safe_intop.c:128 : NaN cannot be converted to an integer. Invalid value + Execution halted ``` # pcalg @@ -245,6 +645,33 @@ Run `revdepcheck::cloud_details(, "pcalg")` for more info +## Newly broken + +* checking tests ... ERROR + ``` + Running ‘test_LINGAM.R’ + Running ‘test_addBgKnowledge.R’ + Running ‘test_adjustment.R’ + Running ‘test_ages.R’ + Running ‘test_amat2dag.R’ + Running ‘test_arges.R’ + Running ‘test_backdoor.R’ + Comparing ‘test_backdoor.Rout’ to ‘test_backdoor.Rout.save’ ... OK + Running ‘test_bicscore.R’ + Running ‘test_causalEffect.R’ + ... + > set.seed(37) + > rD.10.4 <- withCallingHandlers( + + rDAGall(10, 4) # "low-level warning" -- get it here and test it below + + , warning = function(w) { + + rDAG.warn <<- conditionMessage(w); invokeRestart("muffleWarning") }) + > ## with a low-level warning: + > ## IGNORE_RDIFF_BEGIN + > rDAG.warn + Error: object 'rDAG.warn' not found + Execution halted + ``` + ## In both * checking installed package size ... NOTE @@ -299,6 +726,47 @@ Run `revdepcheck::cloud_details(, "phyloseqGraphTest")` for more info +## Newly broken + +* checking examples ... ERROR + ``` + Running examples in ‘phyloseqGraphTest-Ex.R’ failed + The error most likely occurred in: + + > ### Name: plot_test_network + > ### Title: Plots the graph used for testing + > ### Aliases: plot_test_network + > + > ### ** Examples + > + > library(phyloseq) + > data(enterotype) + > gt = graph_perm_test(enterotype, sampletype = "SeqTech") + > plot_test_network(gt) + Error in fortify.igraph(data, ...) : + layout matrix dimensions do not match network size + Calls: plot_test_network ... ggplot -> ggplot.default -> fortify -> fortify.igraph + Execution halted + ``` + +* checking re-building of vignette outputs ... ERROR + ``` + Error(s) in re-building vignettes: + ... + --- re-building ‘gt_vignette.Rmd’ using rmarkdown + + Quitting from lines 175-176 [unnamed-chunk-5] (gt_vignette.Rmd) + Error: processing vignette 'gt_vignette.Rmd' failed with diagnostics: + layout matrix dimensions do not match network size + --- failed re-building ‘gt_vignette.Rmd’ + + SUMMARY: processing the following file failed: + ‘gt_vignette.Rmd’ + + Error: Vignette re-building failed. + Execution halted + ``` + ## In both * checking dependencies in R code ... NOTE @@ -312,42 +780,70 @@ Run `revdepcheck::cloud_details(, "phyloseqGraphTest")` for more info 'LazyData' is specified without a 'data' directory ``` -# shazam +# rgraph6 + +
+ +* Version: 2.0-2 +* GitHub: https://github.com/mbojan/rgraph6 +* Source code: https://github.com/cran/rgraph6 +* Date/Publication: 2022-08-25 12:10:02 UTC +* Number of recursive dependencies: 60 + +Run `revdepcheck::cloud_details(, "rgraph6")` for more info + +
+ +## Newly broken + +* checking re-building of vignette outputs ... ERROR + ``` + Error(s) in re-building vignettes: + ... + --- re-building ‘rgraph6.Rmd’ using rmarkdown + + Quitting from lines 162-171 [unnamed-chunk-9] (rgraph6.Rmd) + Error: processing vignette 'rgraph6.Rmd' failed with diagnostics: + values must be type 'integer', + but FUN(X[[1]]) result is type 'double' + --- failed re-building ‘rgraph6.Rmd’ + + SUMMARY: processing the following file failed: + ‘rgraph6.Rmd’ + + Error: Vignette re-building failed. + Execution halted + ``` + +# riverconn
-* Version: 1.2.0 +* Version: 0.3.28 * GitHub: NA -* Source code: https://github.com/cran/shazam -* Date/Publication: 2023-10-02 18:50:02 UTC -* Number of recursive dependencies: 128 +* Source code: https://github.com/cran/riverconn +* Date/Publication: 2023-05-05 08:20:02 UTC +* Number of recursive dependencies: 96 -Run `revdepcheck::cloud_details(, "shazam")` for more info +Run `revdepcheck::cloud_details(, "riverconn")` for more info
-## In both +## Newly broken -* checking re-building of vignette outputs ... WARNING +* checking re-building of vignette outputs ... ERROR ``` Error(s) in re-building vignettes: - --- re-building ‘Baseline-Vignette.Rmd’ using rmarkdown - tlmgr update --all --self - Can't locate mktexlsr.pl in @INC (@INC contains: /opt/TinyTeX/tlpkg /opt/TinyTeX/texmf-dist/scripts/texlive /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/bin/fmtutil line 26. - BEGIN failed--compilation aborted at /usr/bin/fmtutil line 28. - texlive-scripts package not found (?!), skipping revision consistency check - tlmgr: package repository https://ctan.math.illinois.edu/systems/texlive/tlnet (verified) - tlmgr install: package already present: l3backend - ! LaTeX Error: Mismatched LaTeX support files detected. - (LaTeX) Loading 'l3backend-pdftex.def' aborted! - ... - LaTeX failed to compile /tmp/workdir/shazam/new/shazam.Rcheck/vign_test/shazam/vignettes/Targeting-Vignette.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Targeting-Vignette.log for more info. - --- failed re-building ‘Targeting-Vignette.Rmd’ + ... + --- re-building ‘Tutorial.Rmd’ using rmarkdown - SUMMARY: processing the following files failed: - ‘Baseline-Vignette.Rmd’ ‘DistToNearest-Vignette.Rmd’ - ‘Mutation-Vignette.Rmd’ ‘Shmulate-Vignette.Rmd’ - ‘Targeting-Vignette.Rmd’ + Quitting from lines 210-221 [plot igraph] (Tutorial.Rmd) + Error: processing vignette 'Tutorial.Rmd' failed with diagnostics: + layout matrix dimensions do not match network size + --- failed re-building ‘Tutorial.Rmd’ + + SUMMARY: processing the following file failed: + ‘Tutorial.Rmd’ Error: Vignette re-building failed. Execution halted diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000000..2100f3e8a2e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,29 @@ +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_OPENMP_SUPPORT OFF) +set(IGRAPH_USE_INTERNAL_GLPK OFF) +set(IGRAPH_USE_INTERNAL_LAPACK OFF) +set(IGRAPH_USE_INTERNAL_GMP OFF) +add_subdirectory(vendor/cigraph) + +add_subdirectory(vendor/simpleraytracer) +add_subdirectory(vendor/uuid) diff --git a/src/Makevars.in b/src/Makevars.in index b9c1b2e8ec7..a576244b474 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,14 +1,15 @@ -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=/**/ \ +include sources.mk + +LIB_XML ?= $(MINGW_PREFIX) +GLPK_HOME ?= $(MINGW_PREFIX) +LIB_GMP ?= $(MINGW_PREFIX) + +PKG_CPPFLAGS=@cflags@ -DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor \ + -DNDEBUG -DNTIMER -DNPRINT -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL= \ + -DPRPACK_IGRAPH_SUPPORT \ -D_GNU_SOURCE=1 -PKG_LIBS=@XML2_LIBS@ @GMP_LIBS@ @GLPK_LIBS@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -all: $(SHLIB) +PKG_LIBS = -L${LIB_XML}/lib -lxml2 -lz -lstdc++ -L${GLPK_HOME}/lib \ + -lglpk -lgmp -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=${SOURCES} diff --git a/src/Makevars.ucrt b/src/Makevars.ucrt index 357bc3a60f9..da589b60a82 100644 --- a/src/Makevars.ucrt +++ b/src/Makevars.ucrt @@ -1,15 +1,15 @@ +include sources.mk + LIB_XML ?= $(R_TOOLS_SOFT) GLPK_HOME ?= $(R_TOOLS_SOFT) LIB_GMP ?= $(R_TOOLS_SOFT) -PKG_CPPFLAGS = -I${LIB_XML}/include/libxml2 -I${LIB_XML}/include -DLIBXML_STATIC -DUSING_R \ - -DHAVE_FMEMOPEN=0 -DHAVE_OPEN_MEMSTREAM=0 -DHAVE_RINTF -DHAVE_STRCASECMP -DWin32 \ - -DHAVE_LIBXML=1 -DHAVE_UNISTD_H -Wall -DHAVE_FMIN=1 -DHAVE_LOG2=1 -DHAVE_GFORTRAN \ - -DINTERNAL_ARPACK -I${GLPK_HOME}/include -DHAVE_GLPK=1 -DIGRAPH_THREAD_LOCAL= \ - -DPRPACK_IGRAPH_SUPPORT -I. -Icore -Iinclude -Ivendor -DNDEBUG -DNTIMER -DNPRINT \ - -I${LIB_GMP}/include +PKG_CPPFLAGS = -I${LIB_XML}/include/libxml2 -I${LIB_XML}/include -DLIBXML_STATIC -DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor \ + -DNDEBUG -DNTIMER -DNPRINT -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL= \ + -DPRPACK_IGRAPH_SUPPORT \ + -D_GNU_SOURCE=1 -PKG_LIBS = -L${LIB_XML}/lib -lxml2 -liconv -lz -lws2_32 -lstdc++ -L${GLPK_HOME}/lib \ - -lglpk -lgmp -lgfortran -lquadmath -L$(LIB_GMP)/lib $(BLAS_LIBS) $(LAPACK_LIBS) -llzma +PKG_LIBS = -L${LIB_XML}/lib -lxml2 -liconv -lz -lws2_32 -lstdc++ \ + -lglpk -lgmp $(BLAS_LIBS) $(LAPACK_LIBS) -llzma -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=${SOURCES} diff --git a/src/Makevars.win b/src/Makevars.win index dfaaacbe9f9..ba67ab2e8c9 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,14 +1,15 @@ +include sources.mk + LIB_XML ?= $(MINGW_PREFIX) GLPK_HOME ?= $(MINGW_PREFIX) LIB_GMP ?= $(MINGW_PREFIX) -PKG_CPPFLAGS = -I${LIB_XML}/include/libxml2 -I${LIB_XML}/include -DLIBXML_STATIC -DUSING_R \ - -DHAVE_FMEMOPEN=0 -DHAVE_OPEN_MEMSTREAM=0 -DHAVE_RINTF -DHAVE_STRCASECMP -DWin32 \ - -DHAVE_LIBXML=1 -DHAVE_UNISTD_H -Wall -DHAVE_FMIN=1 -DHAVE_LOG2=1 -DHAVE_GFORTRAN \ - -DINTERNAL_ARPACK -I${GLPK_HOME}/include -DHAVE_GLPK=1 -DIGRAPH_THREAD_LOCAL= \ - -DPRPACK_IGRAPH_SUPPORT -I. -Icore -Iinclude -Ivendor -DNDEBUG -DNTIMER -DNPRINT \ - -I${LIB_GMP}/include +PKG_CPPFLAGS=-DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor \ + -DNDEBUG -DNTIMER -DNPRINT -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL= \ + -DPRPACK_IGRAPH_SUPPORT \ + -D_GNU_SOURCE=1 + +PKG_LIBS = -lxml2 -lz -lstdc++ \ + -lglpk -lgmp $(BLAS_LIBS) $(LAPACK_LIBS) -PKG_LIBS = -L${LIB_XML}/lib -lxml2 -liconv -lz -lws2_32 -lstdc++ -L${GLPK_HOME}/lib \ - -lglpk -lgmp -lgfortran -lquadmath -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=${SOURCES} diff --git a/src/README.md b/src/README.md index 50676d6467b..1a0ee4dc833 100644 --- a/src/README.md +++ b/src/README.md @@ -18,6 +18,11 @@ ``` Note that this may change files generated by `flex` and `bison`, and configure scripts, depending on the version of those tools. + For stability, you can use a Docker image that uses pinned versions of these tools: + ```sh + docker run --rm -ti --platform linux/amd64 -v $(pwd):/root/workspace ghcr.io/cynkra/rig-ubuntu-igraph:main make -f Makefile-cigraph + ``` + 4. Commit and push 5. Optional: Clean submodule ```sh diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 3919e5309df..80251672061 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -22,6 +22,7 @@ extern SEXP R_igraph_add_version_to_env(void *); extern SEXP R_igraph_add_vertices(void *, void *); extern SEXP R_igraph_address(void *); extern SEXP R_igraph_adhesion(void *, void *); +extern SEXP R_igraph_adjacency(void *, void *, void *); extern SEXP R_igraph_adjacency_spectral_embedding(void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_adjacent_triangles(void *, void *); extern SEXP R_igraph_adjacent_vertices(void *, void *, void *); @@ -29,13 +30,14 @@ extern SEXP R_igraph_adjlist(void *, void *, void *); extern SEXP R_igraph_all_minimal_st_separators(void *); extern SEXP R_igraph_all_st_cuts(void *, void *, void *); extern SEXP R_igraph_all_st_mincuts(void *, void *, void *, void *); +extern SEXP R_igraph_almost_equals(void *, void *, void *); extern SEXP R_igraph_are_connected(void *, void *, void *); extern SEXP R_igraph_arpack(void *, void *, void *, void *, void *); extern SEXP R_igraph_arpack_unpack_complex(void *, void *, void *); extern SEXP R_igraph_articulation_points(void *); -extern SEXP R_igraph_assortativity(void *, void *, void *, void *); +extern SEXP R_igraph_assortativity(void *, void *, void *, void *, void *); extern SEXP R_igraph_assortativity_degree(void *, void *); -extern SEXP R_igraph_assortativity_nominal(void *, void *, void *); +extern SEXP R_igraph_assortativity_nominal(void *, void *, void *, void *); extern SEXP R_igraph_asymmetric_preference_game(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_atlas(void *); extern SEXP R_igraph_authority_score(void *, void *, void *, void *); @@ -47,9 +49,13 @@ extern SEXP R_igraph_avg_nearest_neighbor_degree(void *, void *, void *, void *, extern SEXP R_igraph_barabasi_aging_game(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_barabasi_game(void *, void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_betweenness_cutoff(void *, void *, void *, void *, void *); +extern SEXP R_igraph_betweenness_subset(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_bfs(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_bfs_simple(void *, void *, void *); +extern SEXP R_igraph_biadjacency(void *, void *, void *, void *); extern SEXP R_igraph_bibcoupling(void *, void *); extern SEXP R_igraph_biconnected_components(void *); +extern SEXP R_igraph_bipartite_game(void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_bipartite_game_gnm(void *, void *, void *, void *, void *); extern SEXP R_igraph_bipartite_game_gnp(void *, void *, void *, void *, void *); extern SEXP R_igraph_bipartite_projection(void *, void *, void *, void *); @@ -66,13 +72,14 @@ extern SEXP R_igraph_centralization_degree(void *, void *, void *, void *); extern SEXP R_igraph_centralization_degree_tmax(void *, void *, void *, void *); extern SEXP R_igraph_centralization_eigenvector_centrality(void *, void *, void *, void *, void *); extern SEXP R_igraph_centralization_eigenvector_centrality_tmax(void *, void *, void *, void *); +extern SEXP R_igraph_circulant(void *, void *, void *); extern SEXP R_igraph_cited_type_game(void *, void *, void *, void *, void *); extern SEXP R_igraph_citing_cited_type_game(void *, void *, void *, void *, void *); extern SEXP R_igraph_clique_number(void *); extern SEXP R_igraph_clique_size_hist(void *, void *, void *); extern SEXP R_igraph_cliques(void *, void *, void *); extern SEXP R_igraph_closeness_cutoff(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_clusters(void *, void *); +extern SEXP R_igraph_cmp_epsilon(void *, void *, void *); extern SEXP R_igraph_cocitation(void *, void *); extern SEXP R_igraph_cohesion(void *, void *); extern SEXP R_igraph_cohesive_blocks(void *); @@ -80,9 +87,9 @@ extern SEXP R_igraph_community_edge_betweenness(void *, void *, void *, void *, extern SEXP R_igraph_community_fastgreedy(void *, void *, void *, void *, void *); extern SEXP R_igraph_community_fluid_communities(void *, void *); extern SEXP R_igraph_community_infomap(void *, void *, void *, void *); -extern SEXP R_igraph_community_label_propagation(void *, void *, void *, void *); +extern SEXP R_igraph_community_label_propagation(void *, void *, void *, void *, void *); extern SEXP R_igraph_community_leading_eigenvector(void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_community_leiden(void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_community_leiden(void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_community_multilevel(void *, void *, void *); extern SEXP R_igraph_community_optimal_modularity(void *, void *); extern SEXP R_igraph_community_to_membership2(void *, void *, void *); @@ -90,9 +97,11 @@ extern SEXP R_igraph_compare_communities(void *, void *, void *); extern SEXP R_igraph_complementer(void *, void *); extern SEXP R_igraph_compose(void *, void *, void *); extern SEXP R_igraph_connect_neighborhood(void *, void *, void *); +extern SEXP R_igraph_connected_components(void *, void *); extern SEXP R_igraph_constraint(void *, void *, void *); extern SEXP R_igraph_contract_vertices(void *, void *, void *); extern SEXP R_igraph_convex_hull(void *); +extern SEXP R_igraph_copy(void *); extern SEXP R_igraph_copy_env(void *); extern SEXP R_igraph_copy_from(void *); extern SEXP R_igraph_copy_to(void *); @@ -107,28 +116,44 @@ extern SEXP R_igraph_create_bipartite(void *, void *, void *); extern SEXP R_igraph_de_bruijn(void *, void *); extern SEXP R_igraph_decompose(void *, void *, void *, void *); extern SEXP R_igraph_degree(void *, void *, void *, void *); +extern SEXP R_igraph_degree_correlation_vector(void *, void *, void *, void *, void *); extern SEXP R_igraph_degree_sequence_game(void *, void *, void *); extern SEXP R_igraph_delete_edges(void *, void *); extern SEXP R_igraph_delete_vertices(void *, void *); +extern SEXP R_igraph_delete_vertices_idx(void *, void *); extern SEXP R_igraph_density(void *, void *); +extern SEXP R_igraph_deterministic_optimal_imitation(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_dfs(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_diameter(void *, void *, void *, void *); extern SEXP R_igraph_difference(void *, void *); extern SEXP R_igraph_dim_select(void *); extern SEXP R_igraph_disjoint_union(void *); +extern SEXP R_igraph_distances(void *, void *, void *, void *); +extern SEXP R_igraph_distances_bellman_ford(void *, void *, void *, void *, void *); +extern SEXP R_igraph_distances_cutoff(void *, void *, void *, void *, void *); +extern SEXP R_igraph_distances_dijkstra(void *, void *, void *, void *, void *); +extern SEXP R_igraph_distances_dijkstra_cutoff(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_distances_floyd_warshall(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_distances_johnson(void *, void *, void *, void *); extern SEXP R_igraph_diversity(void *, void *, void *); extern SEXP R_igraph_dominator_tree(void *, void *, void *); extern SEXP R_igraph_dot_product_game(void *, void *); extern SEXP R_igraph_dyad_census(void *); +extern SEXP R_igraph_ecc(void *, void *, void *, void *, void *); extern SEXP R_igraph_eccentricity(void *, void *, void *); +extern SEXP R_igraph_eccentricity_dijkstra(void *, void *, void *, void *); extern SEXP R_igraph_ecount(void *); extern SEXP R_igraph_edge_betweenness_cutoff(void *, void *, void *, void *); +extern SEXP R_igraph_edge_betweenness_subset(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_edge_connectivity(void *, void *); extern SEXP R_igraph_edge_disjoint_paths(void *, void *, void *); extern SEXP R_igraph_edges(void *, void *); extern SEXP R_igraph_eigen_adjacency(void *, void *, void *, void *); +extern SEXP R_igraph_eigen_matrix(void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_eigen_matrix_symmetric(void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_eigenvector_centrality(void *, void *, void *, void *, void *); extern SEXP R_igraph_empty(void *, void *); +extern SEXP R_igraph_empty_attrs(void *, void *, void *); extern SEXP R_igraph_erdos_renyi_game(void *, void *, void *, void *, void *); extern SEXP R_igraph_es_adj(void *, void *, void *, void *); extern SEXP R_igraph_es_pairs(void *, void *, void *); @@ -136,39 +161,59 @@ extern SEXP R_igraph_es_path(void *, void *, void *); extern SEXP R_igraph_establishment_game(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_eulerian_cycle(void *); extern SEXP R_igraph_eulerian_path(void *); +extern SEXP R_igraph_even_tarjan_reduction(void *); extern SEXP R_igraph_extended_chordal_ring(void *, void *, void *); extern SEXP R_igraph_famous(void *); extern SEXP R_igraph_farthest_points(void *, void *, void *, void *); extern SEXP R_igraph_feedback_arc_set(void *, void *, void *); extern SEXP R_igraph_finalizer(void); extern SEXP R_igraph_forest_fire_game(void *, void *, void *, void *, void *); +extern SEXP R_igraph_from_hrg_dendrogram(void *); extern SEXP R_igraph_from_prufer(void *); extern SEXP R_igraph_full(void *, void *, void *); extern SEXP R_igraph_full_bipartite(void *, void *, void *, void *); extern SEXP R_igraph_full_citation(void *, void *); -extern SEXP R_igraph_get_adjacency(void *, void *, void *); +extern SEXP R_igraph_full_multipartite(void *, void *, void *); +extern SEXP R_igraph_fundamental_cycles(void *, void *, void *, void *); +extern SEXP R_igraph_generalized_petersen(void *, void *); +extern SEXP R_igraph_get_adjacency(void *, void *, void *, void *); +extern SEXP R_igraph_get_adjacency_sparse(void *, void *, void *, void *); extern SEXP R_igraph_get_adjedgelist(void *, void *, void *); extern SEXP R_igraph_get_adjlist(void *, void *, void *, void *); +extern SEXP R_igraph_get_all_eids_between(void *, void *, void *, void *); extern SEXP R_igraph_get_all_shortest_paths(void *, void *, void *, void *); extern SEXP R_igraph_get_all_shortest_paths_dijkstra(void *, void *, void *, void *, void *); extern SEXP R_igraph_get_all_simple_paths(void *, void *, void *, void *, void *); extern SEXP R_igraph_get_all_simple_paths_pp(void *); extern SEXP R_igraph_get_attr_mode(void *, void *); +extern SEXP R_igraph_get_biadjacency(void *, void *); extern SEXP R_igraph_get_diameter(void *, void *, void *, void *); extern SEXP R_igraph_get_edge(void *, void *); extern SEXP R_igraph_get_edgelist(void *, void *); extern SEXP R_igraph_get_eids(void *, void *, void *, void *, void *); extern SEXP R_igraph_get_graph_id(void *); -extern SEXP R_igraph_get_incidence(void *, void *); extern SEXP R_igraph_get_isomorphisms_vf2(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_get_k_shortest_paths(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_get_laplacian(void *, void *, void *, void *); +extern SEXP R_igraph_get_laplacian_sparse(void *, void *, void *, void *); +extern SEXP R_igraph_get_shortest_path(void *, void *, void *, void *); +extern SEXP R_igraph_get_shortest_path_bellman_ford(void *, void *, void *, void *, void *); +extern SEXP R_igraph_get_shortest_path_dijkstra(void *, void *, void *, void *, void *); extern SEXP R_igraph_get_shortest_paths(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_get_stochastic(void *, void *); +extern SEXP R_igraph_get_stochastic_sparse(void *, void *, void *); extern SEXP R_igraph_get_stochastic_sparsemat(void *, void *); extern SEXP R_igraph_get_subisomorphisms_vf2(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_get_widest_path(void *, void *, void *, void *, void *); +extern SEXP R_igraph_get_widest_paths(void *, void *, void *, void *, void *); extern SEXP R_igraph_getsphere(void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_girth(void *, void *); extern SEXP R_igraph_global_efficiency(void *, void *, void *); -extern SEXP R_igraph_graph_adjacency(void *, void *); +extern SEXP R_igraph_gomory_hu_tree(void *, void *); +extern SEXP R_igraph_graph_center(void *, void *); +extern SEXP R_igraph_graph_center_dijkstra(void *, void *, void *); +extern SEXP R_igraph_graph_count(void *, void *); +extern SEXP R_igraph_graph_power(void *, void *, void *); extern SEXP R_igraph_graph_version(void *); extern SEXP R_igraph_graphlets(void *, void *, void *); extern SEXP R_igraph_graphlets_candidate_basis(void *, void *); @@ -176,16 +221,23 @@ extern SEXP R_igraph_graphlets_project(void *, void *, void *, void *, void *); extern SEXP R_igraph_grg_game(void *, void *, void *, void *); extern SEXP R_igraph_growing_random_game(void *, void *, void *, void *); extern SEXP R_igraph_harmonic_centrality_cutoff(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_has_attribute_table(void *); extern SEXP R_igraph_has_loop(void *); extern SEXP R_igraph_has_multiple(void *); +extern SEXP R_igraph_has_mutual(void *, void *); extern SEXP R_igraph_hrg_consensus(void *, void *, void *, void *); extern SEXP R_igraph_hrg_create(void *, void *); extern SEXP R_igraph_hrg_dendrogram(void *); extern SEXP R_igraph_hrg_fit(void *, void *, void *, void *); extern SEXP R_igraph_hrg_game(void *); extern SEXP R_igraph_hrg_predict(void *, void *, void *, void *, void *); +extern SEXP R_igraph_hrg_resize(void *, void *); +extern SEXP R_igraph_hrg_sample(void *); +extern SEXP R_igraph_hrg_sample_many(void *, void *); +extern SEXP R_igraph_hrg_size(void *); extern SEXP R_igraph_hsbm_game(void *, void *, void *, void *, void *); extern SEXP R_igraph_hsbm_list_game(void *, void *, void *, void *, void *); +extern SEXP R_igraph_hub_and_authority_scores(void *, void *, void *, void *); extern SEXP R_igraph_hub_score(void *, void *, void *, void *); extern SEXP R_igraph_i_levc_arp(void *, void *, void *); extern SEXP R_igraph_identical_graphs(void *, void *, void *); @@ -195,20 +247,24 @@ extern SEXP R_igraph_incident_edges(void *, void *, void *); extern SEXP R_igraph_independence_number(void *); extern SEXP R_igraph_independent_vertex_sets(void *, void *, void *); extern SEXP R_igraph_induced_subgraph(void *, void *, void *); +extern SEXP R_igraph_induced_subgraph_map(void *, void *, void *); extern SEXP R_igraph_intersection(void *, void *); +extern SEXP R_igraph_is_acyclic(void *); extern SEXP R_igraph_is_bipartite(void *); extern SEXP R_igraph_is_chordal(void *, void *, void *, void *, void *); extern SEXP R_igraph_is_connected(void *, void *); extern SEXP R_igraph_is_dag(void *); extern SEXP R_igraph_is_directed(void *); extern SEXP R_igraph_is_eulerian(void *); +extern SEXP R_igraph_is_forest(void *, void *); extern SEXP R_igraph_is_graphical(void *, void *, void *); extern SEXP R_igraph_is_loop(void *, void *); extern SEXP R_igraph_is_matching(void *, void *, void *); extern SEXP R_igraph_is_maximal_matching(void *, void *, void *); extern SEXP R_igraph_is_minimal_separator(void *, void *); extern SEXP R_igraph_is_multiple(void *, void *); -extern SEXP R_igraph_is_mutual(void *, void *); +extern SEXP R_igraph_is_mutual(void *, void *, void *); +extern SEXP R_igraph_is_perfect(void *); extern SEXP R_igraph_is_separator(void *, void *); extern SEXP R_igraph_is_simple(void *); extern SEXP R_igraph_is_tree(void *, void *); @@ -216,10 +272,11 @@ extern SEXP R_igraph_isoclass(void *); extern SEXP R_igraph_isoclass_create(void *, void *, void *); extern SEXP R_igraph_isoclass_subgraph(void *, void *); extern SEXP R_igraph_isomorphic(void *, void *); -extern SEXP R_igraph_isomorphic_34(void *, void *); extern SEXP R_igraph_isomorphic_bliss(void *, void *, void *, void *, void *); extern SEXP R_igraph_isomorphic_vf2(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_joint_degree_matrix(void *, void *, void *, void *); extern SEXP R_igraph_k_regular_game(void *, void *, void *, void *); +extern SEXP R_igraph_kary_tree(void *, void *, void *); extern SEXP R_igraph_kautz(void *, void *); extern SEXP R_igraph_laplacian(void *, void *, void *, void *); extern SEXP R_igraph_laplacian_spectral_embedding(void *, void *, void *, void *, void *, void *, void *); @@ -250,6 +307,9 @@ extern SEXP R_igraph_layout_reingold_tilford(void *, void *, void *, void *, voi extern SEXP R_igraph_layout_sphere(void *); extern SEXP R_igraph_layout_star(void *, void *, void *); extern SEXP R_igraph_layout_sugiyama(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_layout_umap(void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_layout_umap_3d(void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_layout_umap_compute_weights(void *, void *, void *); extern SEXP R_igraph_lcf_vector(void *, void *, void *); extern SEXP R_igraph_linegraph(void *); extern SEXP R_igraph_list_triangles(void *); @@ -261,22 +321,26 @@ extern SEXP R_igraph_local_scan_1_ecount_them(void *, void *, void *, void *); extern SEXP R_igraph_local_scan_k_ecount(void *, void *, void *, void *); extern SEXP R_igraph_local_scan_k_ecount_them(void *, void *, void *, void *, void *); extern SEXP R_igraph_local_scan_neighborhood_ecount(void *, void *, void *); +extern SEXP R_igraph_local_scan_subset_ecount(void *, void *, void *); extern SEXP R_igraph_make_weak_ref(void *, void *, void *); extern SEXP R_igraph_maxflow(void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques(void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques_count(void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques_file(void *, void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques_hist(void *, void *, void *); +extern SEXP R_igraph_maximal_cliques_subset(void *, void *, void *, void *, void *); extern SEXP R_igraph_maximal_independent_vertex_sets(void *); extern SEXP R_igraph_maximum_bipartite_matching(void *, void *, void *, void *); extern SEXP R_igraph_maximum_cardinality_search(void *); extern SEXP R_igraph_mincut(void *, void *); extern SEXP R_igraph_mincut_value(void *, void *); +extern SEXP R_igraph_minimum_cycle_basis(void *, void *, void *, void *, void *); extern SEXP R_igraph_minimum_size_separators(void *); extern SEXP R_igraph_minimum_spanning_tree_prim(void *, void *); extern SEXP R_igraph_minimum_spanning_tree_unweighted(void *); extern SEXP R_igraph_modularity(void *, void *, void *, void *, void *); extern SEXP R_igraph_modularity_matrix(void *, void *, void *, void *); +extern SEXP R_igraph_moran_process(void *, void *, void *, void *, void *); extern SEXP R_igraph_motifs_randesu(void *, void *, void *); extern SEXP R_igraph_motifs_randesu_estimate(void *, void *, void *, void *, void *); extern SEXP R_igraph_motifs_randesu_no(void *, void *, void *); @@ -293,14 +357,20 @@ extern SEXP R_igraph_no_clusters(void *, void *); extern SEXP R_igraph_path_length_hist(void *, void *); extern SEXP R_igraph_permute_vertices(void *, void *); extern SEXP R_igraph_personalized_pagerank(void *, void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_personalized_pagerank_vs(void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_power_law_fit(void *, void *, void *); extern SEXP R_igraph_preference_game(void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_progress(void *, void *); +extern SEXP R_igraph_pseudo_diameter(void *, void *, void *, void *); +extern SEXP R_igraph_pseudo_diameter_dijkstra(void *, void *, void *, void *, void *); extern SEXP R_igraph_radius(void *, void *); +extern SEXP R_igraph_radius_dijkstra(void *, void *, void *); extern SEXP R_igraph_random_edge_walk(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_random_sample(void *, void *, void *); extern SEXP R_igraph_random_spanning_tree(void *, void *); -extern SEXP R_igraph_random_walk(void *, void *, void *, void *, void *); +extern SEXP R_igraph_random_walk(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_read_graph_dimacs(void *, void *); +extern SEXP R_igraph_read_graph_dimacs_flow(void *, void *); extern SEXP R_igraph_read_graph_dl(void *, void *); extern SEXP R_igraph_read_graph_edgelist(void *, void *, void *); extern SEXP R_igraph_read_graph_gml(void *); @@ -312,30 +382,42 @@ extern SEXP R_igraph_read_graph_pajek(void *); extern SEXP R_igraph_realize_degree_sequence(void *, void *, void *, void *); extern SEXP R_igraph_recent_degree_aging_game(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_reciprocity(void *, void *, void *); +extern SEXP R_igraph_regular_tree(void *, void *, void *); +extern SEXP R_igraph_residual_graph(void *, void *, void *); extern SEXP R_igraph_reverse_edges(void *, void *); +extern SEXP R_igraph_reverse_residual_graph(void *, void *, void *); extern SEXP R_igraph_rewire(void *, void *, void *); extern SEXP R_igraph_rewire_directed_edges(void *, void *, void *, void *); extern SEXP R_igraph_rewire_edges(void *, void *, void *, void *); extern SEXP R_igraph_ring(void *, void *, void *, void *); +extern SEXP R_igraph_roots_for_tree_layout(void *, void *, void *); +extern SEXP R_igraph_roulette_wheel_imitation(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_running_mean(void *, void *); extern SEXP R_igraph_sample_dirichlet(void *, void *); extern SEXP R_igraph_sample_sphere_surface(void *, void *, void *, void *); extern SEXP R_igraph_sample_sphere_volume(void *, void *, void *, void *); extern SEXP R_igraph_sbm_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_scg_norm_eps(void *, void *, void *, void *, void *); extern SEXP R_igraph_set_verbose(void *); extern SEXP R_igraph_shortest_paths(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_similarity_dice(void *, void *, void *, void *); +extern SEXP R_igraph_similarity_dice_es(void *, void *, void *, void *); +extern SEXP R_igraph_similarity_dice_pairs(void *, void *, void *, void *); extern SEXP R_igraph_similarity_inverse_log_weighted(void *, void *, void *); extern SEXP R_igraph_similarity_jaccard(void *, void *, void *, void *); +extern SEXP R_igraph_similarity_jaccard_es(void *, void *, void *, void *); +extern SEXP R_igraph_similarity_jaccard_pairs(void *, void *, void *, void *); extern SEXP R_igraph_simple_interconnected_islands_game(void *, void *, void *, void *); extern SEXP R_igraph_simplify(void *, void *, void *, void *); extern SEXP R_igraph_simplify_and_colorize(void *); extern SEXP R_igraph_sir(void *, void *, void *, void *); extern SEXP R_igraph_solve_lsap(void *, void *); +extern SEXP R_igraph_spanner(void *, void *, void *); +extern SEXP R_igraph_sparse_adjacency(void *, void *, void *); +extern SEXP R_igraph_sparse_weighted_adjacency(void *, void *, void *); extern SEXP R_igraph_spinglass_community(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_spinglass_my_community(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_split_join_distance(void *, void *); +extern SEXP R_igraph_square_lattice(void *, void *, void *, void *, void *); extern SEXP R_igraph_st_edge_connectivity(void *, void *, void *); extern SEXP R_igraph_st_mincut(void *, void *, void *, void *); extern SEXP R_igraph_st_mincut_value(void *, void *, void *, void *); @@ -343,29 +425,43 @@ extern SEXP R_igraph_st_vertex_connectivity(void *, void *, void *); extern SEXP R_igraph_star(void *, void *, void *); extern SEXP R_igraph_static_fitness_game(void *, void *, void *, void *, void *); extern SEXP R_igraph_static_power_law_game(void *, void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_status(void *); +extern SEXP R_igraph_stochastic_imitation(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_strength(void *, void *, void *, void *, void *); +extern SEXP R_igraph_strerror(void *); extern SEXP R_igraph_subcomponent(void *, void *, void *); -extern SEXP R_igraph_subgraph_edges(void *, void *, void *); +extern SEXP R_igraph_subgraph_from_edges(void *, void *, void *); +extern SEXP R_igraph_subisomorphic(void *, void *); +extern SEXP R_igraph_subisomorphic_function_vf2(void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_subisomorphic_lad(void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_subisomorphic_vf2(void *, void *, void *, void *, void *, void *); +extern SEXP R_igraph_symmetric_tree(void *, void *); extern SEXP R_igraph_to_directed(void *, void *); extern SEXP R_igraph_to_prufer(void *); extern SEXP R_igraph_to_undirected(void *, void *, void *); extern SEXP R_igraph_topological_sorting(void *, void *); +extern SEXP R_igraph_transitive_closure_dag(void *); extern SEXP R_igraph_transitivity_avglocal_undirected(void *, void *); extern SEXP R_igraph_transitivity_barrat(void *, void *, void *, void *); extern SEXP R_igraph_transitivity_local_undirected(void *, void *, void *); extern SEXP R_igraph_transitivity_local_undirected_all(void *, void *); extern SEXP R_igraph_transitivity_undirected(void *, void *); extern SEXP R_igraph_tree(void *, void *, void *); +extern SEXP R_igraph_tree_from_parent_vector(void *, void *); extern SEXP R_igraph_tree_game(void *, void *, void *); extern SEXP R_igraph_triad_census(void *); +extern SEXP R_igraph_triangular_lattice(void *, void *, void *); +extern SEXP R_igraph_trussness(void *); +extern SEXP R_igraph_turan(void *, void *); extern SEXP R_igraph_unfold_tree(void *, void *, void *); extern SEXP R_igraph_union(void *, void *); extern SEXP R_igraph_vcount(void *); +extern SEXP R_igraph_version(void *); extern SEXP R_igraph_vertex_coloring_greedy(void *, void *); extern SEXP R_igraph_vertex_connectivity(void *, void *); extern SEXP R_igraph_vertex_disjoint_paths(void *, void *, void *); +extern SEXP R_igraph_vertex_path_from_edge_path(void *, void *, void *, void *); +extern SEXP R_igraph_voronoi(void *, void *, void *, void *, void *); extern SEXP R_igraph_vs_adj(void *, void *, void *, void *); extern SEXP R_igraph_vs_nei(void *, void *, void *, void *); extern SEXP R_igraph_walktrap_community(void *, void *, void *, void *, void *, void *); @@ -373,9 +469,13 @@ extern SEXP R_igraph_watts_strogatz_game(void *, void *, void *, void *, void *, extern SEXP R_igraph_weak_ref_key(void *); extern SEXP R_igraph_weak_ref_run_finalizer(void *); extern SEXP R_igraph_weak_ref_value(void *); -extern SEXP R_igraph_weighted_adjacency(void *, void *, void *, void *); +extern SEXP R_igraph_weighted_adjacency(void *, void *, void *); extern SEXP R_igraph_weighted_clique_number(void *, void *); extern SEXP R_igraph_weighted_cliques(void *, void *, void *, void *, void *); +extern SEXP R_igraph_weighted_sparsemat(void *, void *, void *, void *); +extern SEXP R_igraph_wheel(void *, void *, void *); +extern SEXP R_igraph_widest_path_widths_dijkstra(void *, void *, void *, void *, void *); +extern SEXP R_igraph_widest_path_widths_floyd_warshall(void *, void *, void *, void *, void *); extern SEXP R_igraph_write_graph_dimacs(void *, void *, void *, void *, void *); extern SEXP R_igraph_write_graph_dot(void *, void *); extern SEXP R_igraph_write_graph_edgelist(void *, void *); @@ -399,6 +499,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_add_vertices", (DL_FUNC) &R_igraph_add_vertices, 2}, {"R_igraph_address", (DL_FUNC) &R_igraph_address, 1}, {"R_igraph_adhesion", (DL_FUNC) &R_igraph_adhesion, 2}, + {"R_igraph_adjacency", (DL_FUNC) &R_igraph_adjacency, 3}, {"R_igraph_adjacency_spectral_embedding", (DL_FUNC) &R_igraph_adjacency_spectral_embedding, 7}, {"R_igraph_adjacent_triangles", (DL_FUNC) &R_igraph_adjacent_triangles, 2}, {"R_igraph_adjacent_vertices", (DL_FUNC) &R_igraph_adjacent_vertices, 3}, @@ -406,13 +507,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}, @@ -424,9 +526,13 @@ 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_bfs_simple", (DL_FUNC) &R_igraph_bfs_simple, 3}, + {"R_igraph_biadjacency", (DL_FUNC) &R_igraph_biadjacency, 4}, {"R_igraph_bibcoupling", (DL_FUNC) &R_igraph_bibcoupling, 2}, {"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}, @@ -443,13 +549,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}, @@ -457,9 +564,9 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_community_fastgreedy", (DL_FUNC) &R_igraph_community_fastgreedy, 5}, {"R_igraph_community_fluid_communities", (DL_FUNC) &R_igraph_community_fluid_communities, 2}, {"R_igraph_community_infomap", (DL_FUNC) &R_igraph_community_infomap, 4}, - {"R_igraph_community_label_propagation", (DL_FUNC) &R_igraph_community_label_propagation, 4}, + {"R_igraph_community_label_propagation", (DL_FUNC) &R_igraph_community_label_propagation, 5}, {"R_igraph_community_leading_eigenvector", (DL_FUNC) &R_igraph_community_leading_eigenvector, 9}, - {"R_igraph_community_leiden", (DL_FUNC) &R_igraph_community_leiden, 7}, + {"R_igraph_community_leiden", (DL_FUNC) &R_igraph_community_leiden, 8}, {"R_igraph_community_multilevel", (DL_FUNC) &R_igraph_community_multilevel, 3}, {"R_igraph_community_optimal_modularity", (DL_FUNC) &R_igraph_community_optimal_modularity, 2}, {"R_igraph_community_to_membership2", (DL_FUNC) &R_igraph_community_to_membership2, 3}, @@ -467,9 +574,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_copy_env", (DL_FUNC) &R_igraph_copy_env, 1}, {"R_igraph_copy_from", (DL_FUNC) &R_igraph_copy_from, 1}, {"R_igraph_copy_to", (DL_FUNC) &R_igraph_copy_to, 1}, @@ -484,28 +593,44 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_de_bruijn", (DL_FUNC) &R_igraph_de_bruijn, 2}, {"R_igraph_decompose", (DL_FUNC) &R_igraph_decompose, 4}, {"R_igraph_degree", (DL_FUNC) &R_igraph_degree, 4}, + {"R_igraph_degree_correlation_vector", (DL_FUNC) &R_igraph_degree_correlation_vector, 5}, {"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}, @@ -513,39 +638,59 @@ 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}, {"R_igraph_feedback_arc_set", (DL_FUNC) &R_igraph_feedback_arc_set, 3}, {"R_igraph_finalizer", (DL_FUNC) &R_igraph_finalizer, 0}, {"R_igraph_forest_fire_game", (DL_FUNC) &R_igraph_forest_fire_game, 5}, + {"R_igraph_from_hrg_dendrogram", (DL_FUNC) &R_igraph_from_hrg_dendrogram, 1}, {"R_igraph_from_prufer", (DL_FUNC) &R_igraph_from_prufer, 1}, {"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_get_adjacency", (DL_FUNC) &R_igraph_get_adjacency, 3}, + {"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, 4}, + {"R_igraph_get_adjacency_sparse", (DL_FUNC) &R_igraph_get_adjacency_sparse, 4}, {"R_igraph_get_adjedgelist", (DL_FUNC) &R_igraph_get_adjedgelist, 3}, {"R_igraph_get_adjlist", (DL_FUNC) &R_igraph_get_adjlist, 4}, + {"R_igraph_get_all_eids_between", (DL_FUNC) &R_igraph_get_all_eids_between, 4}, {"R_igraph_get_all_shortest_paths", (DL_FUNC) &R_igraph_get_all_shortest_paths, 4}, {"R_igraph_get_all_shortest_paths_dijkstra", (DL_FUNC) &R_igraph_get_all_shortest_paths_dijkstra, 5}, {"R_igraph_get_all_simple_paths", (DL_FUNC) &R_igraph_get_all_simple_paths, 5}, {"R_igraph_get_all_simple_paths_pp", (DL_FUNC) &R_igraph_get_all_simple_paths_pp, 1}, {"R_igraph_get_attr_mode", (DL_FUNC) &R_igraph_get_attr_mode, 2}, + {"R_igraph_get_biadjacency", (DL_FUNC) &R_igraph_get_biadjacency, 2}, {"R_igraph_get_diameter", (DL_FUNC) &R_igraph_get_diameter, 4}, {"R_igraph_get_edge", (DL_FUNC) &R_igraph_get_edge, 2}, {"R_igraph_get_edgelist", (DL_FUNC) &R_igraph_get_edgelist, 2}, {"R_igraph_get_eids", (DL_FUNC) &R_igraph_get_eids, 5}, {"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_sparse", (DL_FUNC) &R_igraph_get_stochastic_sparse, 3}, {"R_igraph_get_stochastic_sparsemat", (DL_FUNC) &R_igraph_get_stochastic_sparsemat, 2}, {"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_graph_adjacency", (DL_FUNC) &R_igraph_graph_adjacency, 2}, + {"R_igraph_gomory_hu_tree", (DL_FUNC) &R_igraph_gomory_hu_tree, 2}, + {"R_igraph_graph_center", (DL_FUNC) &R_igraph_graph_center, 2}, + {"R_igraph_graph_center_dijkstra", (DL_FUNC) &R_igraph_graph_center_dijkstra, 3}, + {"R_igraph_graph_count", (DL_FUNC) &R_igraph_graph_count, 2}, + {"R_igraph_graph_power", (DL_FUNC) &R_igraph_graph_power, 3}, {"R_igraph_graph_version", (DL_FUNC) &R_igraph_graph_version, 1}, {"R_igraph_graphlets", (DL_FUNC) &R_igraph_graphlets, 3}, {"R_igraph_graphlets_candidate_basis", (DL_FUNC) &R_igraph_graphlets_candidate_basis, 2}, @@ -553,16 +698,23 @@ 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_and_authority_scores", (DL_FUNC) &R_igraph_hub_and_authority_scores, 4}, {"R_igraph_hub_score", (DL_FUNC) &R_igraph_hub_score, 4}, {"R_igraph_i_levc_arp", (DL_FUNC) &R_igraph_i_levc_arp, 3}, {"R_igraph_identical_graphs", (DL_FUNC) &R_igraph_identical_graphs, 3}, @@ -572,20 +724,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}, @@ -593,10 +749,11 @@ 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_joint_degree_matrix", (DL_FUNC) &R_igraph_joint_degree_matrix, 4}, {"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}, @@ -627,6 +784,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}, @@ -638,22 +798,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}, @@ -670,14 +834,20 @@ 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_pseudo_diameter", (DL_FUNC) &R_igraph_pseudo_diameter, 4}, + {"R_igraph_pseudo_diameter_dijkstra", (DL_FUNC) &R_igraph_pseudo_diameter_dijkstra, 5}, {"R_igraph_radius", (DL_FUNC) &R_igraph_radius, 2}, + {"R_igraph_radius_dijkstra", (DL_FUNC) &R_igraph_radius_dijkstra, 3}, {"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}, @@ -689,30 +859,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_norm_eps", (DL_FUNC) &R_igraph_scg_norm_eps, 5}, {"R_igraph_set_verbose", (DL_FUNC) &R_igraph_set_verbose, 1}, {"R_igraph_shortest_paths", (DL_FUNC) &R_igraph_shortest_paths, 6}, {"R_igraph_similarity_dice", (DL_FUNC) &R_igraph_similarity_dice, 4}, + {"R_igraph_similarity_dice_es", (DL_FUNC) &R_igraph_similarity_dice_es, 4}, + {"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}, @@ -720,29 +902,43 @@ 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_vertex_path_from_edge_path", (DL_FUNC) &R_igraph_vertex_path_from_edge_path, 4}, + {"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}, @@ -750,9 +946,13 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_weak_ref_key", (DL_FUNC) &R_igraph_weak_ref_key, 1}, {"R_igraph_weak_ref_run_finalizer", (DL_FUNC) &R_igraph_weak_ref_run_finalizer, 1}, {"R_igraph_weak_ref_value", (DL_FUNC) &R_igraph_weak_ref_value, 1}, - {"R_igraph_weighted_adjacency", (DL_FUNC) &R_igraph_weighted_adjacency, 4}, + {"R_igraph_weighted_adjacency", (DL_FUNC) &R_igraph_weighted_adjacency, 3}, {"R_igraph_weighted_clique_number", (DL_FUNC) &R_igraph_weighted_clique_number, 2}, {"R_igraph_weighted_cliques", (DL_FUNC) &R_igraph_weighted_cliques, 5}, + {"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}, diff --git a/src/cpprinterface.cpp b/src/cpprinterface.cpp index d3f4b5dfae1..bc8c9f2b90a 100644 --- a/src/cpprinterface.cpp +++ b/src/cpprinterface.cpp @@ -7,7 +7,7 @@ #include "igraph_vector.hpp" -extern "C" int igraphhcass2(int n, const int *ia, const int *ib, int *iorder, int *iia, int *iib); +extern "C" int igraphhcass2(int n, const int *ia, const int *ib, int *iorder, igraph_integer_t *iia, igraph_integer_t *iib); // FIXME: This belongs in a header or in the cpp11 package const int* ptr(cpp11::integers v) { diff --git a/src/igraph_types.hpp b/src/igraph_types.hpp index fbdc9f1ced8..4ca0bb34f38 100644 --- a/src/igraph_types.hpp +++ b/src/igraph_types.hpp @@ -1 +1 @@ -#include "igraph_types.h" \ No newline at end of file +#include "igraph_types.h" diff --git a/src/igraph_vector.hpp b/src/igraph_vector.hpp index 0ff36ee61a9..bee894edc61 100644 --- a/src/igraph_vector.hpp +++ b/src/igraph_vector.hpp @@ -13,11 +13,11 @@ class igVector { source.vec.stor_begin = nullptr; } - igVector(const igraph_vector_int_t *source) { igraph_vector_int_copy(&vec, source); } + igVector(const igraph_vector_int_t *source) { igraph_vector_int_init_copy(&vec, source); } explicit igVector(long len) { igraph_vector_int_init(&vec, len); } - igVector(const igVector &igv) : igVector() { igraph_vector_int_copy(&vec, &igv.vec); } + igVector(const igVector &igv) : igVector() { igraph_vector_int_init_copy(&vec, &igv.vec); } igVector & operator = (const igVector &igv) { igraph_vector_int_update(&vec, &igv.vec); diff --git a/src/include/igraph_version.h b/src/include/igraph_version.h index cae3cfa1148..fda42278d82 100644 --- a/src/include/igraph_version.h +++ b/src/include/igraph_version.h @@ -34,10 +34,10 @@ __BEGIN_DECLS #define IGRAPH_VERSION_PATCH @PACKAGE_VERSION_PATCH@ #define IGRAPH_VERSION_PRERELEASE "@PACKAGE_VERSION_PRERELEASE@" -IGRAPH_EXPORT int igraph_version(const char **version_string, - int *major, - int *minor, - int *subminor); +IGRAPH_EXPORT void igraph_version(const char **version_string, + int *major, + int *minor, + int *subminor); __END_DECLS diff --git a/src/rinterface.c b/src/rinterface.c index fb11c7515e6..ae59475ad9c 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -22,8 +22,8 @@ */ #include "igraph.h" -#include "graph/attributes.h" -#include "graph/neighbors.h" +#include "igraph_neighborhood.h" +#include "cigraph/src/graph/attributes.h" #include "config.h" @@ -58,25 +58,25 @@ 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_vector_int_list_to_SEXPp1(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); @@ -90,24 +90,25 @@ 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); 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_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it, igraph_vector_int_t *data); +int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it, igraph_vector_int_t *data); 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_vector_list(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_copy(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); @@ -117,11 +118,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); /***********************************************/ @@ -140,7 +141,7 @@ SEXP R_igraph_empty(SEXP n, SEXP directed) { SEXP r_result; /* Convert input */ - c_n=INTEGER(n)[0]; + c_n=(igraph_integer_t) REAL(n)[0]; c_directed=LOGICAL(directed)[0]; /* Call igraph */ IGRAPH_R_CHECK(igraph_empty(&c_graph, c_n, c_directed)); @@ -157,73 +158,126 @@ 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_I_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); + igraph_vector_int_t c_vertices_data; + R_SEXP_to_igraph_vs(vertices, &c_graph, &c_vertices, &c_vertices_data); + 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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + igraph_vector_int_destroy(&c_vertices_data); + igraph_vs_destroy(&c_vertices); + 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_integer_t c_result; + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + c_result=igraph_vcount(&c_graph); + + /* Convert output */ + + PROTECT(r_result=NEW_NUMERIC(1)); + REAL(r_result)[0]=(double) c_result; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_empty_attrs / +/-------------------------------------------*/ +SEXP R_igraph_empty_attrs(SEXP n, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_n; igraph_bool_t c_directed; + SEXP graph; SEXP r_result; /* Convert input */ - c_nodes=INTEGER(nodes)[0]; - R_SEXP_to_matrix(W, &c_W); + c_n=(igraph_integer_t) REAL(n)[0]; c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_extended_chordal_ring(&c_graph, c_nodes, &c_W, c_directed)); + IGRAPH_R_CHECK(igraph_empty_attrs(&c_graph, c_n, c_directed, 0)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -237,55 +291,58 @@ SEXP R_igraph_extended_chordal_ring(SEXP nodes, SEXP W, SEXP directed) { } /*-------------------------------------------/ -/ igraph_lcf_vector / +/ igraph_get_all_eids_between / /-------------------------------------------*/ -SEXP R_igraph_lcf_vector(SEXP n, SEXP shifts, SEXP repeats) { +SEXP R_igraph_get_all_eids_between(SEXP graph, SEXP from, SEXP to, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_vector_t c_shifts; - igraph_integer_t c_repeats; - 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 */ - c_n=INTEGER(n)[0]; - R_SEXP_to_vector(shifts, &c_shifts); - c_repeats=INTEGER(repeats)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_eids, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + 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_lcf_vector(&c_graph, c_n, &c_shifts, c_repeats)); + 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_I_DESTROY(&c_graph); + PROTECT(eids=R_igraph_vector_int_to_SEXPp1(&c_eids)); + igraph_vector_int_destroy(&c_eids); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = eids; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_adjlist / +/ igraph_adjacency / /-------------------------------------------*/ -SEXP R_igraph_adjlist(SEXP adjlist, SEXP mode, SEXP duplicate) { +SEXP R_igraph_adjacency(SEXP adjmatrix, SEXP mode, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_adjlist_t c_adjlist; - igraph_neimode_t c_mode; - igraph_bool_t c_duplicate; + igraph_matrix_t c_adjmatrix; + igraph_adjacency_t c_mode; + igraph_loops_t c_loops; SEXP graph; SEXP r_result; /* Convert input */ - 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]; + R_SEXP_to_matrix(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_adjlist(&c_graph, &c_adjlist, c_mode, c_duplicate)); + IGRAPH_R_CHECK(igraph_adjacency(&c_graph, &c_adjmatrix, c_mode, c_loops)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -299,32 +356,23 @@ SEXP R_igraph_adjlist(SEXP adjlist, SEXP mode, SEXP duplicate) { } /*-------------------------------------------/ -/ 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)); @@ -333,13 +381,13 @@ SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, SEXP directed, SEXP mode) { PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_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); @@ -348,69 +396,82 @@ 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_I_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_weighted_adjacency / /-------------------------------------------*/ -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_weighted_adjacency(SEXP adjmatrix, SEXP mode, SEXP loops) { /* 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_matrix_t c_adjmatrix; + igraph_adjacency_t c_mode; + igraph_vector_t c_weights; + igraph_loops_t c_loops; SEXP graph; - SEXP node_type_vec; + SEXP weights; SEXP r_result, r_names; /* 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)) { + R_SEXP_to_matrix(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_node_type_vec); - c_directed=LOGICAL(directed)[0]; - c_loops=LOGICAL(loops)[0]; + 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_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_weighted_adjacency(&c_graph, &c_adjmatrix, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_loops)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -419,13 +480,13 @@ SEXP R_igraph_preference_game(SEXP nodes, SEXP types, SEXP type_dist, SEXP fixed PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_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); + 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, node_type_vec); + SET_VECTOR_ELT(r_result, 1, weights); SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("node_type_vec")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("weights")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -434,92 +495,68 @@ SEXP R_igraph_preference_game(SEXP nodes, SEXP types, SEXP type_dist, SEXP fixed } /*-------------------------------------------/ -/ igraph_asymmetric_preference_game / +/ igraph_wheel / /-------------------------------------------*/ -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_wheel(SEXP n, SEXP mode, SEXP center) { /* 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_integer_t c_n; + igraph_wheel_mode_t c_mode; + igraph_integer_t c_center; 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]; + c_n=(igraph_integer_t) REAL(n)[0]; + c_mode = (igraph_wheel_mode_t) Rf_asInteger(mode); + c_center=(igraph_integer_t) REAL(center)[0]; /* 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_wheel(&c_graph, c_n, c_mode, c_center)); /* 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_I_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_square_lattice / /-------------------------------------------*/ -SEXP R_igraph_rewire_edges(SEXP graph, SEXP prob, SEXP loops, SEXP multiple) { +SEXP R_igraph_square_lattice(SEXP dimvector, SEXP nei, SEXP directed, SEXP mutual, SEXP periodic) { /* 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_integer_t c_nei; + igraph_bool_t c_directed; + igraph_bool_t c_mutual; + igraph_vector_bool_t c_periodic; + 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_copy(dimvector, &c_dimvector); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_dimvector); + c_nei=(igraph_integer_t) REAL(nei)[0]; + c_directed=LOGICAL(directed)[0]; + c_mutual=LOGICAL(mutual)[0]; + if (!Rf_isNull(periodic)) { + R_SEXP_to_vector_bool(periodic, &c_periodic); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_rewire_edges(&c_graph, c_prob, c_loops, c_multiple)); + IGRAPH_R_CHECK(igraph_square_lattice(&c_graph, &c_dimvector, c_nei, c_directed, c_mutual, (Rf_isNull(periodic) ? 0 : &c_periodic))); /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_dimvector); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -527,29 +564,32 @@ SEXP R_igraph_rewire_edges(SEXP graph, SEXP prob, SEXP loops, SEXP multiple) { } /*-------------------------------------------/ -/ igraph_rewire_directed_edges / +/ igraph_triangular_lattice / /-------------------------------------------*/ -SEXP R_igraph_rewire_directed_edges(SEXP graph, SEXP prob, SEXP loops, SEXP mode) { +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_neimode_t c_mode; + 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_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_vector_int_copy(dimvector, &c_dimvector); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_dimvector); + c_directed=LOGICAL(directed)[0]; + c_mutual=LOGICAL(mutual)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_rewire_directed_edges(&c_graph, c_prob, c_loops, c_mode)); + 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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_dimvector); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -557,27 +597,23 @@ SEXP R_igraph_rewire_directed_edges(SEXP graph, SEXP prob, SEXP loops, SEXP mode } /*-------------------------------------------/ -/ igraph_forest_fire_game / +/ igraph_kary_tree / /-------------------------------------------*/ -SEXP R_igraph_forest_fire_game(SEXP nodes, SEXP fw_prob, SEXP bw_factor, SEXP ambs, SEXP directed) { +SEXP R_igraph_kary_tree(SEXP n, SEXP children, 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_integer_t c_n; + igraph_integer_t c_children; + 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]; + c_n=(igraph_integer_t) REAL(n)[0]; + c_children=(igraph_integer_t) REAL(children)[0]; + 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_kary_tree(&c_graph, c_n, c_children, c_type)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -591,33 +627,30 @@ SEXP R_igraph_forest_fire_game(SEXP nodes, SEXP fw_prob, SEXP bw_factor, SEXP am } /*-------------------------------------------/ -/ igraph_static_fitness_game / +/ igraph_symmetric_tree / /-------------------------------------------*/ -SEXP R_igraph_static_fitness_game(SEXP no_of_edges, SEXP fitness_out, SEXP fitness_in, SEXP loops, SEXP multiple) { +SEXP R_igraph_symmetric_tree(SEXP branches, 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_vector_int_t c_branches; + 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]; + R_SEXP_to_vector_int_copy(branches, &c_branches); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_branches); + 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_symmetric_tree(&c_graph, &c_branches, c_type)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_branches); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -625,31 +658,23 @@ SEXP R_igraph_static_fitness_game(SEXP no_of_edges, SEXP fitness_out, SEXP fitne } /*-------------------------------------------/ -/ igraph_static_power_law_game / +/ igraph_regular_tree / /-------------------------------------------*/ -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_regular_tree(SEXP h, SEXP k, SEXP type) { /* 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_h; + igraph_integer_t c_k; + igraph_tree_mode_t c_type; 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_h=(igraph_integer_t) REAL(h)[0]; + c_k=(igraph_integer_t) REAL(k)[0]; + c_type = (igraph_tree_mode_t) Rf_asInteger(type); /* 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_regular_tree(&c_graph, c_h, c_k, c_type)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -663,25 +688,21 @@ SEXP R_igraph_static_power_law_game(SEXP no_of_nodes, SEXP no_of_edges, SEXP exp } /*-------------------------------------------/ -/ igraph_k_regular_game / +/ igraph_full_citation / /-------------------------------------------*/ -SEXP R_igraph_k_regular_game(SEXP no_of_nodes, SEXP k, SEXP directed, SEXP multiple) { +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_k; + igraph_integer_t c_n; 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_n=(igraph_integer_t) REAL(n)[0]; 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_full_citation(&c_graph, c_n, c_directed)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -695,35 +716,31 @@ SEXP R_igraph_k_regular_game(SEXP no_of_nodes, SEXP k, SEXP directed, SEXP multi } /*-------------------------------------------/ -/ igraph_sbm_game / +/ igraph_extended_chordal_ring / /-------------------------------------------*/ -SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed, SEXP loops) { +SEXP R_igraph_extended_chordal_ring(SEXP nodes, SEXP W, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_matrix_t c_pref_matrix; - igraph_vector_int_t c_block_sizes; + igraph_integer_t c_nodes; + igraph_matrix_int_t c_W; igraph_bool_t c_directed; - igraph_bool_t c_loops; 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_copy(block_sizes, &c_block_sizes); - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_block_sizes); + c_nodes=(igraph_integer_t) REAL(nodes)[0]; + R_SEXP_to_matrix_int(W, &c_W); + IGRAPH_FINALLY(igraph_matrix_int_destroy, &c_W); c_directed=LOGICAL(directed)[0]; - c_loops=LOGICAL(loops)[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_extended_chordal_ring(&c_graph, c_nodes, &c_W, c_directed)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_block_sizes); + igraph_matrix_int_destroy(&c_W); IGRAPH_FINALLY_CLEAN(1); r_result = graph; @@ -732,69 +749,61 @@ SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed } /*-------------------------------------------/ -/ igraph_hsbm_game / +/ igraph_graph_power / /-------------------------------------------*/ -SEXP R_igraph_hsbm_game(SEXP n, SEXP m, SEXP rho, SEXP C, SEXP p) { +SEXP R_igraph_graph_power(SEXP graph, SEXP order, SEXP directed) { /* 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; - SEXP graph; + igraph_t c_res; + igraph_integer_t c_order; + igraph_bool_t c_directed; + SEXP res; 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]; + R_SEXP_to_igraph(graph, &c_graph); + c_order=(igraph_integer_t) REAL(order)[0]; + c_directed=LOGICAL(directed)[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_graph_power(&c_graph, &c_res, c_order, c_directed)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hsbm_list_game / +/ igraph_lcf_vector / /-------------------------------------------*/ -SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP p) { +SEXP R_igraph_lcf_vector(SEXP n, SEXP shifts, SEXP repeats) { /* 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_int_t c_shifts; + igraph_integer_t c_repeats; SEXP graph; SEXP r_result; /* Convert input */ - c_n=INTEGER(n)[0]; - R_SEXP_to_vector_int_copy(mlist, &c_mlist); - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_mlist); - R_igraph_SEXP_to_vectorlist(rholist, &c_rholist); - R_igraph_SEXP_to_matrixlist(Clist, &c_Clist); - c_p=REAL(p)[0]; + c_n=(igraph_integer_t) REAL(n)[0]; + R_SEXP_to_vector_int_copy(shifts, &c_shifts); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_shifts); + c_repeats=(igraph_integer_t) REAL(repeats)[0]; /* 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_lcf_vector(&c_graph, c_n, &c_shifts, c_repeats)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_mlist); + igraph_vector_int_destroy(&c_shifts); IGRAPH_FINALLY_CLEAN(1); r_result = graph; @@ -803,77 +812,79 @@ SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP } /*-------------------------------------------/ -/ igraph_correlated_game / +/ igraph_adjlist / /-------------------------------------------*/ -SEXP R_igraph_correlated_game(SEXP old_graph, SEXP corr, SEXP p, SEXP permutation) { +SEXP R_igraph_adjlist(SEXP adjlist, SEXP mode, SEXP duplicate) { /* 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; + igraph_t c_graph; + igraph_adjlist_t c_adjlist; + igraph_neimode_t c_mode; + igraph_bool_t c_duplicate; + SEXP 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); } + 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_correlated_game(&c_old_graph, &c_new_graph, c_corr, c_p, (Rf_isNull(permutation) ? 0 : &c_permutation))); + IGRAPH_R_CHECK(igraph_adjlist(&c_graph, &c_adjlist, c_mode, c_duplicate)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_new_graph); - PROTECT(new_graph=R_igraph_to_SEXP(&c_new_graph)); - IGRAPH_I_DESTROY(&c_new_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = new_graph; + igraph_adjlist_destroy(&c_adjlist); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_correlated_pair_game / +/ igraph_full_bipartite / /-------------------------------------------*/ -SEXP R_igraph_correlated_pair_game(SEXP n, SEXP corr, SEXP p, SEXP directed, SEXP permutation) { +SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, 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_bool_t c_types; + igraph_integer_t c_n1; + igraph_integer_t c_n2; 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_bool_init(&c_types, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_n1=(igraph_integer_t) REAL(n1)[0]; + c_n2=(igraph_integer_t) REAL(n2)[0]; 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_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_graph1); - PROTECT(graph1=R_igraph_to_SEXP(&c_graph1)); - IGRAPH_I_DESTROY(&c_graph1); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - IGRAPH_FINALLY(igraph_destroy, &c_graph2); - PROTECT(graph2=R_igraph_to_SEXP(&c_graph2)); - IGRAPH_I_DESTROY(&c_graph2); + 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, 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); @@ -882,303 +893,280 @@ SEXP R_igraph_correlated_pair_game(SEXP n, SEXP corr, SEXP p, SEXP directed, SEX } /*-------------------------------------------/ -/ igraph_dot_product_game / +/ igraph_full_multipartite / /-------------------------------------------*/ -SEXP R_igraph_dot_product_game(SEXP vecs, SEXP directed) { +SEXP R_igraph_full_multipartite(SEXP n, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_vecs; + igraph_vector_int_t c_types; + igraph_vector_int_t c_n; igraph_bool_t c_directed; + igraph_neimode_t c_mode; SEXP graph; + SEXP types; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_matrix(vecs, &c_vecs); + 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_copy(n, &c_n); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_n); c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_dot_product_game(&c_graph, &c_vecs, c_directed)); + 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_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(types=R_igraph_vector_int_to_SEXPp1(&c_types)); + igraph_vector_int_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_n); + 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_sample_sphere_surface / +/ igraph_realize_degree_sequence / /-------------------------------------------*/ -SEXP R_igraph_sample_sphere_surface(SEXP dim, SEXP n, SEXP radius, SEXP positive) { +SEXP R_igraph_realize_degree_sequence(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types, SEXP method) { /* Declarations */ - 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; + igraph_t c_graph; + 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 */ - 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); + R_SEXP_to_vector_int_copy(out_deg, &c_out_deg); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_out_deg); + if (!Rf_isNull(in_deg)) { + R_SEXP_to_vector_int_copy(in_deg, &c_in_deg); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_in_deg); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_in_deg, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_in_deg); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + 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_sample_sphere_surface(c_dim, c_n, c_radius, c_positive, &c_res)); + 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 */ - 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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + igraph_vector_int_destroy(&c_out_deg); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_in_deg); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_sample_sphere_volume / +/ igraph_circulant / /-------------------------------------------*/ -SEXP R_igraph_sample_sphere_volume(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); + c_n=(igraph_integer_t) REAL(n)[0]; + R_SEXP_to_vector_int_copy(shifts, &c_shifts); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_shifts); + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_sample_sphere_volume(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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + igraph_vector_int_destroy(&c_shifts); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_sample_dirichlet / +/ igraph_generalized_petersen / /-------------------------------------------*/ -SEXP R_igraph_sample_dirichlet(SEXP n, SEXP alpha) { +SEXP R_igraph_generalized_petersen(SEXP n, SEXP k) { /* Declarations */ + igraph_t c_graph; igraph_integer_t c_n; - igraph_vector_t c_alpha; - igraph_matrix_t c_res; - SEXP res; + igraph_integer_t c_k; + SEXP graph; SEXP r_result; /* Convert input */ - 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); + c_n=(igraph_integer_t) REAL(n)[0]; + c_k=(igraph_integer_t) REAL(k)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_sample_dirichlet(c_n, &c_alpha, &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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_closeness / +/ igraph_turan / /-------------------------------------------*/ -SEXP R_igraph_closeness(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized) { +SEXP R_igraph_turan(SEXP n, SEXP r) { /* 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_vector_int_t c_types; + igraph_integer_t c_n; + igraph_integer_t c_r; + SEXP graph; + SEXP types; 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_init(&c_reachable_count, 0)) { + if (0 != igraph_vector_int_init(&c_types, 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]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_types); + c_n=(igraph_integer_t) REAL(n)[0]; + c_r=(igraph_integer_t) REAL(r)[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_turan(&c_graph, &c_types, c_n, c_r)); /* 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)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(reachable_count=R_igraph_0orvector_to_SEXP(&c_reachable_count)); - igraph_vector_destroy(&c_reachable_count); + PROTECT(types=R_igraph_vector_int_to_SEXPp1(&c_types)); + igraph_vector_int_destroy(&c_types); 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_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_closeness_cutoff / +/ igraph_weighted_sparsemat / /-------------------------------------------*/ -SEXP R_igraph_closeness_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized, SEXP cutoff) { +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; - igraph_real_t c_cutoff; - 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]; - c_cutoff=REAL(cutoff)[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_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_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_I_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=(igraph_integer_t) REAL(nodes)[0]; + c_types=(igraph_integer_t) REAL(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_I_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); @@ -1187,394 +1175,370 @@ 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=(igraph_integer_t) REAL(nodes)[0]; + c_out_types=(igraph_integer_t) REAL(out_types)[0]; + c_in_types=(igraph_integer_t) REAL(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_I_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_I_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_I_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=(igraph_integer_t) REAL(nodes)[0]; + c_fw_prob=REAL(fw_prob)[0]; + c_bw_factor=REAL(bw_factor)[0]; + c_ambs=(igraph_integer_t) REAL(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_I_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); + c_no_of_edges=(igraph_integer_t) REAL(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); } - 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_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, (Rf_isNull(fitness_in) ? 0 : &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_I_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=(igraph_integer_t) REAL(no_of_nodes)[0]; + c_no_of_edges=(igraph_integer_t) REAL(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_I_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=(igraph_integer_t) REAL(no_of_nodes)[0]; + c_k=(igraph_integer_t) REAL(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_I_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=(igraph_integer_t) REAL(n)[0]; + R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); + R_SEXP_to_vector_int_copy(block_sizes, &c_block_sizes); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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_I_DESTROY(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + igraph_vector_int_destroy(&c_block_sizes); + IGRAPH_FINALLY_CLEAN(1); + 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=(igraph_integer_t) REAL(n)[0]; + c_m=(igraph_integer_t) REAL(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_I_DESTROY(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_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; + 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=(igraph_integer_t) REAL(n)[0]; + R_SEXP_to_vector_int_copy(mlist, &c_mlist); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_mlist); + R_igraph_SEXP_to_vector_list(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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_eids); + igraph_vector_int_destroy(&c_mlist); + IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -1582,81 +1546,93 @@ 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]; + if (!Rf_isNull(permutation)) { + R_SEXP_to_vector_int_copy(permutation, &c_permutation); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_permutation); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_permutation, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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, (Rf_isNull(permutation) ? 0 : &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_I_DESTROY(&c_new_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_permutation); + 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=(igraph_integer_t) REAL(n)[0]; + c_corr=REAL(corr)[0]; + c_p=REAL(p)[0]; c_directed=LOGICAL(directed)[0]; + if (!Rf_isNull(permutation)) { + R_SEXP_to_vector_int_copy(permutation, &c_permutation); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_permutation); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_permutation, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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, (Rf_isNull(permutation) ? 0 : &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_I_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_I_DESTROY(&c_graph2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_permutation); + 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); @@ -1665,32 +1641,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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_attribute_combination_destroy(&c_edge_attr_comb); - IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -1698,64 +1669,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=(igraph_integer_t) REAL(dim)[0]; + c_n=(igraph_integer_t) REAL(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=(igraph_integer_t) REAL(dim)[0]; + c_n=(igraph_integer_t) REAL(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); @@ -1763,23 +1739,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=(igraph_integer_t) REAL(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); @@ -1787,79 +1770,166 @@ 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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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; + igraph_vector_int_destroy(&c_vids_data); + 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); 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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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; + igraph_vector_int_destroy(&c_vids_data); + 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); 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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); r_result = res; UNPROTECT(1); @@ -1867,23 +1937,42 @@ 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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); r_result = res; UNPROTECT(1); @@ -1891,179 +1980,220 @@ 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_SEXPp1(&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_SEXPp1(&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 : (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_SEXPp1(&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_SEXPp1(&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 : (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_SEXPp1(&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_SEXPp1(&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_all_shortest_paths / /-------------------------------------------*/ -SEXP R_igraph_authority_score(SEXP graph, SEXP scale, SEXP weights, SEXP options) { +SEXP R_igraph_get_all_shortest_paths(SEXP graph, SEXP from, SEXP to, SEXP mode) { /* Declarations */ igraph_t c_graph; - 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; + 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 */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { + if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - 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); + 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_vector_int_destroy, &c_nrgeo); + c_from = (igraph_integer_t) REAL(from)[0]; + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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_all_shortest_paths(&c_graph, &c_vertices, &c_edges, &c_nrgeo, c_from, c_to, 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(vertices=R_igraph_vector_int_list_to_SEXPp1(&c_vertices)); + igraph_vector_int_list_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_list_to_SEXPp1(&c_edges)); + igraph_vector_int_list_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(nrgeo=R_igraph_vector_int_to_SEXP(&c_nrgeo)); + igraph_vector_int_destroy(&c_nrgeo); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + 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("vpaths")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("epaths")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("nrgeo")); SET_NAMES(r_result, r_names); UNPROTECT(4); @@ -2072,259 +2202,283 @@ SEXP R_igraph_authority_score(SEXP graph, SEXP scale, SEXP weights, SEXP options } /*-------------------------------------------/ -/ igraph_arpack_unpack_complex / +/ igraph_distances_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_arpack_unpack_complex(SEXP vectors, SEXP values, SEXP nev) { +SEXP R_igraph_distances_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ - igraph_matrix_t c_vectors; - igraph_matrix_t c_values; - long int c_nev; + 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; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* 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)) { + 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_values); - c_nev=INTEGER(nev)[0]; + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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_arpack_unpack_complex(&c_vectors, &c_values, c_nev)); + 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)); - 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); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_unfold_tree / +/ igraph_distances_dijkstra_cutoff / /-------------------------------------------*/ -SEXP R_igraph_unfold_tree(SEXP graph, SEXP mode, SEXP roots) { +SEXP R_igraph_distances_dijkstra_cutoff(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode, SEXP cutoff) { /* 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; + igraph_real_t c_cutoff; + 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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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_unfold_tree(&c_graph, &c_tree, c_mode, &c_roots, (Rf_isNull(vertex_index) ? 0 : &c_vertex_index))); + 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(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_I_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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_mutual / +/ igraph_get_all_shortest_paths_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_is_mutual(SEXP graph, SEXP es) { +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_bool_t c_res; - igraph_es_t c_es; - SEXP res; + 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; + 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_int_list_init(&c_vertices, 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_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_vector_int_destroy, &c_nrgeo); + c_from = (igraph_integer_t) REAL(from)[0]; + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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_is_mutual(&c_graph, &c_res, c_es)); + 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(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(vertices=R_igraph_vector_int_list_to_SEXPp1(&c_vertices)); + igraph_vector_int_list_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_es); - r_result = res; + PROTECT(edges=R_igraph_vector_int_list_to_SEXPp1(&c_edges)); + igraph_vector_int_list_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(nrgeo=R_igraph_vector_int_to_SEXP(&c_nrgeo)); + igraph_vector_int_destroy(&c_nrgeo); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + 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("vpaths")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("epaths")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("nrgeo")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_maximum_cardinality_search / +/ igraph_distances_bellman_ford / /-------------------------------------------*/ -SEXP R_igraph_maximum_cardinality_search(SEXP graph) { +SEXP R_igraph_distances_bellman_ford(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_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_alpha, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_alpha); - if (0 != igraph_vector_init(&c_alpham1, 0)) { + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_alpham1); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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_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)); - PROTECT(alpha=R_igraph_vector_to_SEXPp1(&c_alpha)); - igraph_vector_destroy(&c_alpha); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(alpham1=R_igraph_vector_to_SEXPp1(&c_alpham1)); - igraph_vector_destroy(&c_alpham1); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_avg_nearest_neighbor_degree / +/ igraph_distances_johnson / /-------------------------------------------*/ -SEXP R_igraph_avg_nearest_neighbor_degree(SEXP graph, SEXP vids, SEXP mode, SEXP neighbor_degree_mode, SEXP weights) { +SEXP R_igraph_distances_johnson(SEXP graph, SEXP from, SEXP to, SEXP weights) { /* 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; + 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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* 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_johnson(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights))); /* 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_strength / +/ igraph_distances_floyd_warshall / /-------------------------------------------*/ -SEXP R_igraph_strength(SEXP graph, SEXP vids, SEXP mode, SEXP loops, SEXP weights) { +SEXP R_igraph_distances_floyd_warshall(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode, SEXP method) { /* 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; + igraph_neimode_t c_mode; + igraph_floyd_warshall_algorithm_t c_method; 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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); 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 */ - 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_floyd_warshall(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, c_method)); /* 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); r_result = res; UNPROTECT(1); @@ -2332,263 +2486,364 @@ SEXP R_igraph_strength(SEXP graph, SEXP vids, SEXP mode, SEXP loops, SEXP weight } /*-------------------------------------------/ -/ igraph_centralization / +/ igraph_voronoi / /-------------------------------------------*/ -SEXP R_igraph_centralization(SEXP scores, SEXP theoretical_max, SEXP normalized) { +SEXP R_igraph_voronoi(SEXP graph, SEXP generators, SEXP weights, SEXP mode, SEXP tiebreaker) { /* Declarations */ - igraph_vector_t c_scores; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; - igraph_real_t c_result; - SEXP r_result; + igraph_t c_graph; + 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_voronoi_tiebreaker_t c_tiebreaker; + SEXP membership; + SEXP distances; + + SEXP r_result, r_names; /* 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_vector_int_init(&c_membership, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + 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_copy(generators, &c_generators); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_tiebreaker = (igraph_voronoi_tiebreaker_t) Rf_asInteger(tiebreaker); /* Call igraph */ - c_result=igraph_centralization(&c_scores, 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_NUMERIC(1)); - REAL(r_result)[0]=c_result; + 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(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(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_degree / +/ igraph_get_all_simple_paths / /-------------------------------------------*/ -SEXP R_igraph_centralization_degree(SEXP graph, SEXP mode, SEXP loops, SEXP normalized) { +SEXP R_igraph_get_all_simple_paths(SEXP graph, SEXP from, SEXP to, SEXP cutoff, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + 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_centralization; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; SEXP res; - SEXP centralization; - SEXP theoretical_max; - 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)) { + if (0 != igraph_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_from = (igraph_integer_t) REAL(from)[0]; + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + c_cutoff=(igraph_integer_t) REAL(cutoff)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_loops=LOGICAL(loops)[0]; - c_normalized=LOGICAL(normalized)[0]; /* 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_get_all_simple_paths(&c_graph, &c_res, c_from, c_to, c_cutoff, 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); + PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); + igraph_vector_int_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")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_degree_tmax / +/ igraph_get_k_shortest_paths / /-------------------------------------------*/ -SEXP R_igraph_centralization_degree_tmax(SEXP graph, SEXP nodes, SEXP mode, SEXP loops) { +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_integer_t c_nodes; + 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; - igraph_bool_t c_loops; - igraph_real_t c_res; - SEXP res; + SEXP vertex_paths; + SEXP edge_paths; - 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]; + R_SEXP_to_igraph(graph, &c_graph); + 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_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=(igraph_integer_t) REAL(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); - 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_k_shortest_paths(&c_graph, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), &c_vertex_paths, &c_edge_paths, c_k, c_from, c_to, 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(vertex_paths=R_igraph_vector_int_list_to_SEXPp1(&c_vertex_paths)); + igraph_vector_int_list_destroy(&c_vertex_paths); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_paths=R_igraph_vector_int_list_to_SEXPp1(&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(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_betweenness / +/ igraph_get_widest_path / /-------------------------------------------*/ -SEXP R_igraph_centralization_betweenness(SEXP graph, SEXP directed, SEXP normalized) { +SEXP R_igraph_get_widest_path(SEXP graph, SEXP from, SEXP to, SEXP weights, 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_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, 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); - c_directed=LOGICAL(directed)[0]; - c_normalized=LOGICAL(normalized)[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); } + 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_widest_path(&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(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_SEXPp1(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); 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(edges=R_igraph_vector_int_to_SEXPp1(&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_centralization_betweenness_tmax / +/ igraph_get_widest_paths / /-------------------------------------------*/ -SEXP R_igraph_centralization_betweenness_tmax(SEXP graph, SEXP nodes, SEXP directed) { +SEXP R_igraph_get_widest_paths(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_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_vector_int_t c_parents; + igraph_vector_int_t c_inbound_edges; + SEXP vertices; + SEXP edges; + SEXP parents; + SEXP inbound_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_list_init(&c_vertices, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + 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]; + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + 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_betweenness_tmax((Rf_isNull(graph) ? 0 : &c_graph), c_nodes, c_directed, &c_res)); + 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(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(vertices=R_igraph_vector_int_list_to_SEXPp1(&c_vertices)); + igraph_vector_int_list_destroy(&c_vertices); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edges=R_igraph_vector_int_list_to_SEXPp1(&c_edges)); + igraph_vector_int_list_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + 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(5); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_closeness / +/ igraph_widest_path_widths_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_centralization_closeness(SEXP graph, SEXP mode, SEXP normalized) { +SEXP R_igraph_widest_path_widths_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + 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_centralization; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; SEXP res; - SEXP centralization; - SEXP theoretical_max; - 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)) { + 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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_normalized=LOGICAL(normalized)[0]; /* 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_widest_path_widths_dijkstra(&c_graph, &c_res, 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(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); - 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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_closeness_tmax / +/ igraph_widest_path_widths_floyd_warshall / /-------------------------------------------*/ -SEXP R_igraph_centralization_closeness_tmax(SEXP graph, SEXP nodes, SEXP mode) { +SEXP R_igraph_widest_path_widths_floyd_warshall(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); + igraph_vector_int_t c_from_data; + R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); + igraph_vector_int_t c_to_data; + R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); + 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_floyd_warshall(&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); + igraph_vector_int_destroy(&c_from_data); + igraph_vs_destroy(&c_from); + igraph_vector_int_destroy(&c_to_data); + igraph_vs_destroy(&c_to); r_result = res; UNPROTECT(1); @@ -2596,92 +2851,72 @@ SEXP R_igraph_centralization_closeness_tmax(SEXP graph, SEXP nodes, SEXP mode) { } /*-------------------------------------------/ -/ igraph_centralization_eigenvector_centrality / +/ igraph_spanner / /-------------------------------------------*/ -SEXP R_igraph_centralization_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP options, SEXP normalized) { +SEXP R_igraph_spanner(SEXP graph, SEXP stretch, SEXP weights) { /* 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_vector_int_t c_spanner; + igraph_real_t c_stretch; + igraph_vector_t c_weights; + SEXP spanner; - 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_vector_int_init(&c_spanner, 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_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(&c_graph, &c_vector, &c_value, c_directed, c_scale, &c_options, &c_centralization, &c_theoretical_max, c_normalized)); + IGRAPH_R_CHECK(igraph_spanner(&c_graph, &c_spanner, c_stretch, (Rf_isNull(weights) ? 0 : &c_weights))); /* 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(spanner=R_igraph_vector_int_to_SEXPp1(&c_spanner)); + igraph_vector_int_destroy(&c_spanner); 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 = spanner; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_eigenvector_centrality_tmax / +/ igraph_betweenness_cutoff / /-------------------------------------------*/ -SEXP R_igraph_centralization_eigenvector_centrality_tmax(SEXP graph, SEXP nodes, SEXP directed, SEXP scale) { +SEXP R_igraph_betweenness_cutoff(SEXP graph, SEXP vids, SEXP directed, SEXP weights, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; + igraph_vector_t c_res; + igraph_vs_t c_vids; igraph_bool_t c_directed; - igraph_bool_t c_scale; - igraph_real_t c_res; + igraph_vector_t c_weights; + igraph_real_t c_cutoff; 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_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_directed=LOGICAL(directed)[0]; - c_scale=LOGICAL(scale)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_cutoff=REAL(cutoff)[0]; /* 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_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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); r_result = res; UNPROTECT(1); @@ -2689,27 +2924,47 @@ SEXP R_igraph_centralization_eigenvector_centrality_tmax(SEXP graph, SEXP nodes, } /*-------------------------------------------/ -/ igraph_assortativity_nominal / +/ igraph_betweenness_subset / /-------------------------------------------*/ -SEXP R_igraph_assortativity_nominal(SEXP graph, SEXP types, 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_types; - 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(types, &c_types); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_directed=LOGICAL(directed)[0]; + igraph_vector_int_t c_sources_data; + R_SEXP_to_igraph_vs(sources, &c_graph, &c_sources, &c_sources_data); + igraph_vector_int_t c_targets_data; + R_SEXP_to_igraph_vs(targets, &c_graph, &c_targets, &c_targets_data); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_assortativity_nominal(&c_graph, &c_types, &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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + igraph_vector_int_destroy(&c_sources_data); + igraph_vs_destroy(&c_sources); + igraph_vector_int_destroy(&c_targets_data); + igraph_vs_destroy(&c_targets); r_result = res; UNPROTECT(1); @@ -2717,29 +2972,32 @@ SEXP R_igraph_assortativity_nominal(SEXP graph, SEXP types, SEXP directed) { } /*-------------------------------------------/ -/ igraph_assortativity / +/ igraph_edge_betweenness / /-------------------------------------------*/ -SEXP R_igraph_assortativity(SEXP graph, SEXP types1, SEXP types2, SEXP directed) { +SEXP R_igraph_edge_betweenness(SEXP graph, SEXP directed, 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_bool_t c_directed; + 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_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); @@ -2747,25 +3005,34 @@ SEXP R_igraph_assortativity(SEXP graph, SEXP types1, SEXP types2, SEXP directed) } /*-------------------------------------------/ -/ igraph_assortativity_degree / +/ igraph_edge_betweenness_cutoff / /-------------------------------------------*/ -SEXP R_igraph_assortativity_degree(SEXP graph, SEXP directed) { +SEXP R_igraph_edge_betweenness_cutoff(SEXP graph, SEXP directed, SEXP weights, SEXP cutoff) { /* 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; + igraph_real_t c_cutoff; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_directed=LOGICAL(directed)[0]; - /* Call igraph */ - IGRAPH_R_CHECK(igraph_assortativity_degree(&c_graph, &c_res, c_directed)); + 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_edge_betweenness_cutoff(&c_graph, &c_res, 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); @@ -2773,45 +3040,65 @@ SEXP R_igraph_assortativity_degree(SEXP graph, SEXP directed) { } /*-------------------------------------------/ -/ igraph_contract_vertices / +/ igraph_edge_betweenness_subset / /-------------------------------------------*/ -SEXP R_igraph_contract_vertices(SEXP graph, SEXP mapping, SEXP vertex_attr_comb) { +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_mapping; - igraph_attribute_combination_t c_vertex_attr_comb; + igraph_vector_t c_res; + 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; /* 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); + igraph_vector_int_t c_eids_data; + R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + c_directed=LOGICAL(directed)[0]; + igraph_vector_int_t c_sources_data; + R_SEXP_to_igraph_vs(sources, &c_graph, &c_sources, &c_sources_data); + igraph_vector_int_t c_targets_data; + R_SEXP_to_igraph_vs(targets, &c_graph, &c_targets, &c_targets_data); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_contract_vertices(&c_graph, &c_mapping, &c_vertex_attr_comb)); + 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(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_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; + igraph_vector_int_destroy(&c_eids_data); + igraph_es_destroy(&c_eids); + igraph_vector_int_destroy(&c_sources_data); + igraph_vs_destroy(&c_sources); + igraph_vector_int_destroy(&c_targets_data); + igraph_vs_destroy(&c_targets); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eccentricity / +/ igraph_harmonic_centrality_cutoff / /-------------------------------------------*/ -SEXP R_igraph_eccentricity(SEXP graph, SEXP vids, 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_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; SEXP r_result; @@ -2821,15 +3108,20 @@ 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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); 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_eccentricity(&c_graph, &c_res, c_vids, 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(res=R_igraph_vector_to_SEXP(&c_res)); igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vids_data); igraph_vs_destroy(&c_vids); r_result = res; @@ -2838,669 +3130,612 @@ SEXP R_igraph_eccentricity(SEXP graph, SEXP vids, SEXP mode) { } /*-------------------------------------------/ -/ igraph_radius / +/ igraph_personalized_pagerank / /-------------------------------------------*/ -SEXP R_igraph_radius(SEXP graph, SEXP mode) { +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_real_t c_radius; - igraph_neimode_t c_mode; - SEXP radius; + 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_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); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + 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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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; + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_radius(&c_graph, &c_radius, c_mode)); + 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 : (Rf_isNull(weights) ? 0 : &c_weights)), c_options)); /* Convert output */ - PROTECT(radius=NEW_NUMERIC(1)); - REAL(radius)[0]=c_radius; - r_result = radius; + 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; + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { + PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); + } 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_diversity / +/ igraph_personalized_pagerank_vs / /-------------------------------------------*/ -SEXP R_igraph_diversity(SEXP graph, SEXP weights, SEXP vids) { +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_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_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 (!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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + c_directed=LOGICAL(directed)[0]; + c_damping=REAL(damping)[0]; + igraph_vector_int_t c_reset_vids_data; + R_SEXP_to_igraph_vs(reset_vids, &c_graph, &c_reset_vids, &c_reset_vids_data); + 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_vs(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, c_reset_vids, (Rf_isNull(weights) ? 0 : (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); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + igraph_vector_int_destroy(&c_vids_data); igraph_vs_destroy(&c_vids); - r_result = res; + igraph_vector_int_destroy(&c_reset_vids_data); + igraph_vs_destroy(&c_reset_vids); + if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { + PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); + } 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_induced_subgraph / /-------------------------------------------*/ -SEXP R_igraph_random_walk(SEXP graph, 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_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_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 (0 != igraph_vector_init(&c_walk, 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_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + c_impl = (igraph_subgraph_implementation_t) Rf_asInteger(impl); /* Call igraph */ - IGRAPH_R_CHECK(igraph_random_walk(&c_graph, &c_walk, 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(walk=R_igraph_vector_to_SEXPp1(&c_walk)); - igraph_vector_destroy(&c_walk); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = walk; + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_random_edge_walk / +/ igraph_subgraph_from_edges / /-------------------------------------------*/ -SEXP R_igraph_random_edge_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { +SEXP R_igraph_subgraph_from_edges(SEXP graph, SEXP eids, SEXP delete_vertices) { /* 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_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); } - 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); + igraph_vector_int_t c_eids_data; + R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + c_delete_vertices=LOGICAL(delete_vertices)[0]; /* 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_subgraph_from_edges(&c_graph, &c_res, c_eids, c_delete_vertices)); /* 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_I_DESTROY(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = edgewalk; + igraph_vector_int_destroy(&c_eids_data); + igraph_es_destroy(&c_eids); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_global_efficiency / +/ igraph_reverse_edges / /-------------------------------------------*/ -SEXP R_igraph_global_efficiency(SEXP graph, SEXP weights, SEXP directed) { +SEXP R_igraph_reverse_edges(SEXP graph, SEXP eids) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_res; - igraph_vector_t c_weights; - igraph_bool_t c_directed; - SEXP res; + igraph_es_t c_eids; 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]; + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + igraph_vector_int_t c_eids_data; + R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); /* Call igraph */ - IGRAPH_R_CHECK(igraph_global_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed)); + IGRAPH_R_CHECK(igraph_reverse_edges(&c_graph, c_eids)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - r_result = res; + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_eids_data); + igraph_es_destroy(&c_eids); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_efficiency / +/ igraph_average_path_length_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_local_efficiency(SEXP graph, SEXP vids, 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_vector_t c_res; - igraph_vs_t c_vids; + 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 (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); + c_unconn=LOGICAL(unconn)[0]; /* 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_average_path_length_dijkstra(&c_graph, &c_res, &c_unconn_pairs, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_unconn)); /* 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; + 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); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_average_local_efficiency / +/ igraph_path_length_hist / /-------------------------------------------*/ -SEXP R_igraph_average_local_efficiency(SEXP graph, SEXP weights, SEXP directed, SEXP mode) { +SEXP R_igraph_path_length_hist(SEXP graph, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_res; - igraph_vector_t c_weights; + igraph_vector_t c_res; + igraph_real_t c_unconnected; igraph_bool_t c_directed; - igraph_neimode_t c_mode; SEXP res; + SEXP unconnected; - 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)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* 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_path_length_hist(&c_graph, &c_res, &c_unconnected, c_directed)); /* 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(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_is_graphical / +/ igraph_simplify / /-------------------------------------------*/ -SEXP R_igraph_is_graphical(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types) { +SEXP R_igraph_simplify(SEXP graph, SEXP remove_multiple, SEXP remove_loops, SEXP edge_attr_comb) { /* 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; - SEXP res; + igraph_t c_graph; + igraph_bool_t c_remove_multiple; + igraph_bool_t c_remove_loops; + igraph_attribute_combination_t c_edge_attr_comb; SEXP r_result; /* 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_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_is_graphical(&c_out_deg, (Rf_isNull(in_deg) ? 0 : &c_in_deg), c_allowed_edge_types, &c_res)); + IGRAPH_R_CHECK(igraph_simplify(&c_graph, c_remove_multiple, c_remove_loops, &c_edge_attr_comb)); /* Convert output */ - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - r_result = res; + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_attribute_combination_destroy(&c_edge_attr_comb); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_bipartite_projection_size / +/ igraph_ecc / /-------------------------------------------*/ -SEXP R_igraph_bipartite_projection_size(SEXP graph, SEXP types) { +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_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_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, 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; + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_eids_data; + R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + c_k=(igraph_integer_t) REAL(k)[0]; + c_offset=LOGICAL(offset)[0]; + c_normalize=LOGICAL(normalize)[0]; /* 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_ecc(&c_graph, &c_res, c_eids, c_k, c_offset, c_normalize)); /* 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(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_eids_data); + igraph_es_destroy(&c_eids); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_create_bipartite / +/ igraph_feedback_arc_set / /-------------------------------------------*/ -SEXP R_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { +SEXP R_igraph_feedback_arc_set(SEXP graph, SEXP weights, SEXP algo) { /* 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_int_t c_result; + igraph_vector_t c_weights; + igraph_fas_algorithm_t c_algo; + SEXP result; SEXP r_result; /* Convert input */ - R_SEXP_to_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_int_init(&c_result, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + 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_create_bipartite(&c_graph, &c_types, &c_edges, c_directed)); + IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, (Rf_isNull(weights) ? 0 : &c_weights), c_algo)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); + PROTECT(result=R_igraph_vector_int_to_SEXPp1(&c_result)); + igraph_vector_int_destroy(&c_result); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = result; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_incidence / +/ igraph_is_loop / /-------------------------------------------*/ -SEXP R_igraph_incidence(SEXP incidence, SEXP directed, SEXP mode, SEXP multiple) { +SEXP R_igraph_is_loop(SEXP graph, SEXP es) { /* 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_bool_t c_res; + igraph_es_t c_es; + SEXP res; - 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_bool_init(&c_res, 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_bool_destroy, &c_res); + igraph_vector_int_t c_es_data; + R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); /* Call igraph */ - IGRAPH_R_CHECK(igraph_incidence(&c_graph, &c_types, &c_incidence, c_directed, c_mode, c_multiple)); + IGRAPH_R_CHECK(igraph_is_loop(&c_graph, &c_res, c_es)); /* 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_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); - igraph_vector_bool_destroy(&c_types); + 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, 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); + igraph_vector_int_destroy(&c_es_data); + igraph_es_destroy(&c_es); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_incidence / +/ igraph_is_dag / /-------------------------------------------*/ -SEXP R_igraph_get_incidence(SEXP graph, SEXP types) { +SEXP R_igraph_is_dag(SEXP graph) { /* 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_bool_t c_res; 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)) { - 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 */ /* 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_dag(&c_graph, &c_res)); /* 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); - 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); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_bipartite / +/ igraph_is_acyclic / /-------------------------------------------*/ -SEXP R_igraph_is_bipartite(SEXP graph) { +SEXP R_igraph_is_acyclic(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_acyclic(&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_simple / /-------------------------------------------*/ -SEXP R_igraph_bipartite_game_gnp(SEXP n1, SEXP n2, SEXP p, 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_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_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_I_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_multiple / /-------------------------------------------*/ -SEXP R_igraph_bipartite_game_gnm(SEXP n1, SEXP n2, SEXP m, SEXP directed, SEXP mode) { +SEXP R_igraph_is_multiple(SEXP graph, SEXP es) { /* 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_vector_bool_t c_res; + igraph_es_t c_es; + SEXP res; - 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_bool_init(&c_res, 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); + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); + igraph_vector_int_t c_es_data; + R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); /* 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_multiple(&c_graph, &c_res, c_es)); /* 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_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(types=R_igraph_0orvector_bool_to_SEXP(&c_types)); - igraph_vector_bool_destroy(&c_types); + 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, 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); + igraph_vector_int_destroy(&c_es_data); + igraph_es_destroy(&c_es); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_clusters / +/ igraph_has_loop / /-------------------------------------------*/ -SEXP R_igraph_clusters(SEXP graph, SEXP mode) { +SEXP R_igraph_has_loop(SEXP graph) { /* 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_bool_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_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - if (0 != igraph_vector_init(&c_csize, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_csize); - c_no=0; - c_mode=REAL(mode)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_clusters(&c_graph, &c_membership, &c_csize, &c_no, c_mode)); + IGRAPH_R_CHECK(igraph_has_loop(&c_graph, &c_res)); /* 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); - 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); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_connected / +/ igraph_has_multiple / /-------------------------------------------*/ -SEXP R_igraph_is_connected(SEXP graph, SEXP mode) { +SEXP R_igraph_has_multiple(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_multiple(&c_graph, &c_res)); /* Convert output */ PROTECT(res=NEW_LOGICAL(1)); @@ -3512,28 +3747,33 @@ SEXP R_igraph_is_connected(SEXP graph, SEXP mode) { } /*-------------------------------------------/ -/ igraph_articulation_points / +/ igraph_count_multiple / /-------------------------------------------*/ -SEXP R_igraph_articulation_points(SEXP graph) { +SEXP R_igraph_count_multiple(SEXP graph, SEXP es) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_vector_int_t c_res; + igraph_es_t c_es; 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_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + igraph_vector_int_t c_es_data; + R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); /* Call igraph */ - IGRAPH_R_CHECK(igraph_articulation_points(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_count_multiple(&c_graph, &c_res, c_es)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXPp1(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_es_data); + igraph_es_destroy(&c_es); r_result = res; UNPROTECT(1); @@ -3541,292 +3781,343 @@ SEXP R_igraph_articulation_points(SEXP graph) { } /*-------------------------------------------/ -/ igraph_biconnected_components / +/ igraph_is_perfect / /-------------------------------------------*/ -SEXP R_igraph_biconnected_components(SEXP graph) { +SEXP R_igraph_is_perfect(SEXP graph) { /* 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_bool_t c_res; + 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)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_articulation_points); /* 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_is_perfect(&c_graph, &c_res)); /* 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); - 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); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_bridges / +/ igraph_eigenvector_centrality / /-------------------------------------------*/ -SEXP R_igraph_bridges(SEXP graph) { +SEXP R_igraph_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - 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_init(&c_res, 0)) { + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + 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_bridges(&c_graph, &c_res)); + 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_vector_to_SEXPp1(&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); - 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_cliques / +/ igraph_hub_score / /-------------------------------------------*/ -SEXP R_igraph_cliques(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_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_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_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_hub_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); - IGRAPH_FINALLY_CLEAN(1); - r_result = 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); + 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_authority_score / /-------------------------------------------*/ -SEXP R_igraph_clique_size_hist(SEXP graph, SEXP min_size, SEXP max_size) { +SEXP R_igraph_authority_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_authority_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); + 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 = hist; + 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_hub_and_authority_scores / /-------------------------------------------*/ -SEXP R_igraph_largest_cliques(SEXP graph) { +SEXP R_igraph_hub_and_authority_scores(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_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_ptr_init(&c_res, 0)) { + if (0 != igraph_vector_init(&c_hub_vector, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + 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(R_igraph_vectorlist_destroy, &c_res); + 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_largest_cliques(&c_graph, &c_res)); + 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(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + 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 = res; + 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_maximal_cliques_hist / +/ igraph_unfold_tree / /-------------------------------------------*/ -SEXP R_igraph_maximal_cliques_hist(SEXP graph, SEXP min_size, SEXP max_size) { +SEXP R_igraph_unfold_tree(SEXP graph, SEXP mode, SEXP roots) { /* 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_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); - if (0 != igraph_vector_init(&c_hist, 0)) { + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_vector_int_copy(roots, &c_roots); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_roots); + if (0 != igraph_vector_int_init(&c_vertex_index, 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_int_destroy, &c_vertex_index); /* Call igraph */ - IGRAPH_R_CHECK(igraph_maximal_cliques_hist(&c_graph, &c_hist, c_min_size, c_max_size)); + IGRAPH_R_CHECK(igraph_unfold_tree(&c_graph, &c_tree, c_mode, &c_roots, &c_vertex_index)); /* Convert output */ - PROTECT(hist=R_igraph_vector_to_SEXP(&c_hist)); - igraph_vector_destroy(&c_hist); + 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_I_DESTROY(&c_tree); IGRAPH_FINALLY_CLEAN(1); - r_result = hist; + igraph_vector_int_destroy(&c_roots); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(vertex_index=R_igraph_vector_int_to_SEXPp1(&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_clique_number / +/ igraph_is_mutual / /-------------------------------------------*/ -SEXP R_igraph_clique_number(SEXP graph) { +SEXP R_igraph_is_mutual(SEXP graph, SEXP es, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no; - SEXP no; + 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); - c_no=0; + if (0 != igraph_vector_bool_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); + igraph_vector_int_t c_es_data; + R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_clique_number(&c_graph, &c_no)); + IGRAPH_R_CHECK(igraph_is_mutual(&c_graph, &c_res, c_es, c_loops)); /* Convert output */ - PROTECT(no=NEW_INTEGER(1)); - INTEGER(no)[0]=c_no; - r_result = no; + PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); + igraph_vector_bool_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_es_data); + igraph_es_destroy(&c_es); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_weighted_cliques / +/ igraph_has_mutual / /-------------------------------------------*/ -SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, SEXP max_weight, SEXP maximal) { +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_real_t c_min_weight; - igraph_real_t c_max_weight; - igraph_bool_t c_maximal; + 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_min_weight=REAL(min_weight)[0]; - c_max_weight=REAL(max_weight)[0]; - c_maximal=LOGICAL(maximal)[0]; + 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_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); @@ -3834,120 +4125,177 @@ SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, } /*-------------------------------------------/ -/ igraph_largest_weighted_cliques / +/ igraph_maximum_cardinality_search / /-------------------------------------------*/ -SEXP R_igraph_largest_weighted_cliques(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_vector_ptr_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_ptr_init(&c_res, 0)) { + 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(R_igraph_vectorlist_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_alpham1); /* 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_maximum_cardinality_search(&c_graph, &c_alpha, &c_alpham1)); /* Convert output */ - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(alpha=R_igraph_vector_int_to_SEXPp1(&c_alpha)); + igraph_vector_int_destroy(&c_alpha); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(alpham1=R_igraph_vector_int_to_SEXPp1(&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_weighted_clique_number / +/ igraph_avg_nearest_neighbor_degree / /-------------------------------------------*/ -SEXP R_igraph_weighted_clique_number(SEXP graph, SEXP vertex_weights) { +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_vector_t c_vertex_weights; - igraph_real_t c_res; - 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 (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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)) { + 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_weighted_clique_number(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + 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=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + igraph_vector_int_destroy(&c_vids_data); + 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_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_star / +/ igraph_degree_correlation_vector / /-------------------------------------------*/ -SEXP R_igraph_layout_star(SEXP graph, SEXP center, SEXP order) { +SEXP R_igraph_degree_correlation_vector(SEXP graph, SEXP weights, SEXP from_mode, SEXP to_mode, SEXP directed_neighbors) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_integer_t c_center; - igraph_vector_t c_order; - SEXP res; + igraph_vector_t c_weights; + igraph_vector_t c_knnk; + igraph_neimode_t c_from_mode; + igraph_neimode_t c_to_mode; + igraph_bool_t c_directed_neighbors; + SEXP knnk; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != igraph_vector_init(&c_knnk, 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_knnk); + c_from_mode = (igraph_neimode_t) Rf_asInteger(from_mode); + c_to_mode = (igraph_neimode_t) Rf_asInteger(to_mode); + c_directed_neighbors=LOGICAL(directed_neighbors)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_star(&c_graph, &c_res, c_center, (Rf_isNull(order) ? 0 : &c_order))); + IGRAPH_R_CHECK(igraph_degree_correlation_vector(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_knnk, c_from_mode, c_to_mode, c_directed_neighbors)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(knnk=R_igraph_vector_to_SEXP(&c_knnk)); + igraph_vector_destroy(&c_knnk); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = knnk; 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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); r_result = res; UNPROTECT(1); @@ -3955,104 +4303,109 @@ 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); + if (!Rf_isNull(graph)) { + R_SEXP_to_igraph(graph, &c_graph); } - 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=(igraph_integer_t) REAL(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((Rf_isNull(graph) ? 0 : &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); @@ -4060,63 +4413,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_I_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); @@ -4125,32 +4463,29 @@ 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); + if (!Rf_isNull(graph)) { + R_SEXP_to_igraph(graph, &c_graph); } - 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=(igraph_integer_t) REAL(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((Rf_isNull(graph) ? 0 : &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); @@ -4158,74 +4493,79 @@ 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); + if (!Rf_isNull(graph)) { + R_SEXP_to_igraph(graph, &c_graph); } - 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=(igraph_integer_t) REAL(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((Rf_isNull(graph) ? 0 : &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); @@ -4233,81 +4573,94 @@ 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); + if (!Rf_isNull(graph)) { + R_SEXP_to_igraph(graph, &c_graph); } - 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=(igraph_integer_t) REAL(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((Rf_isNull(graph) ? 0 : &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); @@ -4315,35 +4668,32 @@ 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_copy(types, &c_types); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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_vector_int_destroy(&c_types); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4351,33 +4701,33 @@ 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); + R_SEXP_to_vector(values, &c_values); + if (!Rf_isNull(values_in)) { + R_SEXP_to_vector(values_in, &c_values_in); } - 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_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, (Rf_isNull(values_in) ? 0 : &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); @@ -4385,23 +4735,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)); @@ -4413,564 +4761,447 @@ SEXP R_igraph_compare_communities(SEXP comm1, SEXP comm2, SEXP method) { } /*-------------------------------------------/ -/ igraph_modularity / +/ igraph_joint_degree_matrix / /-------------------------------------------*/ -SEXP R_igraph_modularity(SEXP graph, SEXP membership, SEXP weights, SEXP resolution, SEXP directed) { +SEXP R_igraph_joint_degree_matrix(SEXP graph, SEXP weights, SEXP max_out_degree, SEXP max_in_degree) { /* 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_matrix_t c_jdm; + igraph_integer_t c_max_out_degree; + igraph_integer_t c_max_in_degree; + SEXP jdm; 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]; + if (0 != igraph_matrix_init(&c_jdm, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_jdm); + c_max_out_degree=(igraph_integer_t) REAL(max_out_degree)[0]; + c_max_in_degree=(igraph_integer_t) REAL(max_in_degree)[0]; /* 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_joint_degree_matrix(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_jdm, c_max_out_degree, c_max_in_degree)); /* Convert output */ - PROTECT(modularity=NEW_NUMERIC(1)); - REAL(modularity)[0]=c_modularity; - r_result = modularity; + PROTECT(jdm=R_igraph_matrix_to_SEXP(&c_jdm)); + igraph_matrix_destroy(&c_jdm); + IGRAPH_FINALLY_CLEAN(1); + r_result = jdm; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_modularity_matrix / +/ igraph_joint_degree_distribution / /-------------------------------------------*/ -SEXP R_igraph_modularity_matrix(SEXP graph, SEXP weights, SEXP resolution, SEXP directed) { +SEXP R_igraph_joint_degree_distribution(SEXP graph, SEXP weights, SEXP from_mode, SEXP to_mode, SEXP directed_neighbors, SEXP normalized, SEXP max_from_degree, SEXP max_to_degree) { /* 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_matrix_t c_p; + igraph_neimode_t c_from_mode; + igraph_neimode_t c_to_mode; + igraph_bool_t c_directed_neighbors; + igraph_bool_t c_normalized; + igraph_integer_t c_max_from_degree; + igraph_integer_t c_max_to_degree; + SEXP p; 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_matrix_init(&c_p, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_modmat); - c_directed=LOGICAL(directed)[0]; + IGRAPH_FINALLY(igraph_matrix_destroy, &c_p); + c_from_mode = (igraph_neimode_t) Rf_asInteger(from_mode); + c_to_mode = (igraph_neimode_t) Rf_asInteger(to_mode); + c_directed_neighbors=LOGICAL(directed_neighbors)[0]; + c_normalized=LOGICAL(normalized)[0]; + c_max_from_degree=(igraph_integer_t) REAL(max_from_degree)[0]; + c_max_to_degree=(igraph_integer_t) REAL(max_to_degree)[0]; /* 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_joint_degree_distribution(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_p, c_from_mode, c_to_mode, c_directed_neighbors, c_normalized, c_max_from_degree, c_max_to_degree)); /* Convert output */ - PROTECT(modmat=R_igraph_matrix_to_SEXP(&c_modmat)); - igraph_matrix_destroy(&c_modmat); + PROTECT(p=R_igraph_matrix_to_SEXP(&c_p)); + igraph_matrix_destroy(&c_p); IGRAPH_FINALLY_CLEAN(1); - r_result = modmat; + r_result = p; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_fluid_communities / +/ igraph_joint_type_distribution / /-------------------------------------------*/ -SEXP R_igraph_community_fluid_communities(SEXP graph, SEXP no_of_communities) { +SEXP R_igraph_joint_type_distribution(SEXP graph, SEXP weights, SEXP from_types, SEXP to_types, SEXP directed, SEXP normalized) { /* 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_matrix_t c_p; + igraph_vector_int_t c_from_types; + igraph_vector_int_t c_to_types; + igraph_bool_t c_directed; + igraph_bool_t c_normalized; + SEXP p; - 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_matrix_init(&c_p, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_p); + R_SEXP_to_vector_int_copy(from_types, &c_from_types); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_from_types); + R_SEXP_to_vector_int_copy(to_types, &c_to_types); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_to_types); + c_directed=LOGICAL(directed)[0]; + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_fluid_communities(&c_graph, c_no_of_communities, &c_membership, &c_modularity)); + IGRAPH_R_CHECK(igraph_joint_type_distribution(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_p, &c_from_types, &c_to_types, c_directed, c_normalized)); /* 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(p=R_igraph_matrix_to_SEXP(&c_p)); + igraph_matrix_destroy(&c_p); 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); + igraph_vector_int_destroy(&c_from_types); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_to_types); + IGRAPH_FINALLY_CLEAN(1); + r_result = p; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_label_propagation / +/ igraph_contract_vertices / /-------------------------------------------*/ -SEXP R_igraph_community_label_propagation(SEXP graph, SEXP weights, SEXP initial, SEXP fixed) { +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_vector_t c_initial; - igraph_vector_bool_t c_fixed; - igraph_real_t c_modularity; - SEXP membership; - SEXP modularity; + igraph_vector_int_t c_mapping; + igraph_attribute_combination_t c_vertex_attr_comb; - 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 (!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); } + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + R_SEXP_to_vector_int_copy(mapping, &c_mapping); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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_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_contract_vertices(&c_graph, &c_mapping, &c_vertex_attr_comb)); /* 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(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); 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); + igraph_vector_int_destroy(&c_mapping); + 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_community_multilevel / +/ igraph_eccentricity / /-------------------------------------------*/ -SEXP R_igraph_community_multilevel(SEXP graph, SEXP weights, SEXP resolution) { +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_vector_t c_membership; - igraph_matrix_t c_memberships; - igraph_vector_t c_modularity; - SEXP membership; - SEXP memberships; - SEXP modularity; + 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); - 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)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_modularity); - modularity=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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_eccentricity(&c_graph, &c_res, c_vids, 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); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); 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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_optimal_modularity / +/ igraph_eccentricity_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_community_optimal_modularity(SEXP graph, SEXP weights) { +SEXP R_igraph_eccentricity_dijkstra(SEXP graph, SEXP weights, SEXP vids, SEXP mode) { /* 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_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); - 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); - membership=R_GlobalEnv; /* hack to have a non-NULL value */ - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* 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_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(modularity=NEW_NUMERIC(1)); - REAL(modularity)[0]=c_modularity; - PROTECT(membership=R_igraph_0orvector_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); - 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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_leiden / +/ igraph_graph_center / /-------------------------------------------*/ -SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SEXP resolution_parameter, SEXP beta, SEXP start, SEXP membership) { +SEXP R_igraph_graph_center(SEXP graph, SEXP mode) { /* 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_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 (!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); - } + if (0 != igraph_vector_int_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - membership=NEW_NUMERIC(0); - c_nb_clusters=0; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* 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_graph_center(&c_graph, &c_res, c_mode)); /* 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); + PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); + igraph_vector_int_destroy(&c_res); 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); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_split_join_distance / +/ igraph_graph_center_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_split_join_distance(SEXP comm1, SEXP comm2) { +SEXP R_igraph_graph_center_dijkstra(SEXP graph, SEXP weights, SEXP mode) { /* 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_int_t c_res; + igraph_neimode_t c_mode; + 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_int_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_split_join_distance(&c_comm1, &c_comm2, &c_distance12, &c_distance21)); + IGRAPH_R_CHECK(igraph_graph_center_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_mode)); /* 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_int_to_SEXPp1(&c_res)); + igraph_vector_int_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_fit / +/ igraph_radius / /-------------------------------------------*/ -SEXP R_igraph_hrg_fit(SEXP graph, SEXP hrg, SEXP start, SEXP steps) { +SEXP R_igraph_radius(SEXP graph, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - igraph_bool_t c_start; - int c_steps; + igraph_real_t c_radius; + igraph_neimode_t c_mode; + SEXP radius; 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]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_fit(&c_graph, &c_hrg, c_start, c_steps)); + IGRAPH_R_CHECK(igraph_radius(&c_graph, &c_radius, c_mode)); /* Convert output */ - PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); - igraph_hrg_destroy(&c_hrg); - IGRAPH_FINALLY_CLEAN(1); - r_result = hrg; + PROTECT(radius=NEW_NUMERIC(1)); + REAL(radius)[0]=c_radius; + r_result = radius; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_game / +/ igraph_radius_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_hrg_game(SEXP hrg) { +SEXP R_igraph_radius_dijkstra(SEXP graph, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - SEXP graph; + igraph_vector_t c_weights; + igraph_real_t c_radius; + igraph_neimode_t c_mode; + SEXP radius; 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_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_game(&c_graph, &c_hrg)); + IGRAPH_R_CHECK(igraph_radius_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_radius, c_mode)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(radius=NEW_NUMERIC(1)); + REAL(radius)[0]=c_radius; + r_result = radius; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_dendrogram / +/ igraph_pseudo_diameter / /-------------------------------------------*/ -SEXP R_igraph_hrg_dendrogram(SEXP hrg) { +SEXP R_igraph_pseudo_diameter(SEXP graph, SEXP start_vid, SEXP directed, SEXP unconnected) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - SEXP graph; + 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; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_hrg(hrg, &c_hrg); + R_SEXP_to_igraph(graph, &c_graph); + 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_hrg_dendrogram(&c_graph, &c_hrg)); + IGRAPH_R_CHECK(igraph_pseudo_diameter(&c_graph, &c_diameter, c_start_vid, &c_from, &c_to, c_directed, c_unconnected)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + 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_NUMERIC(1)); + REAL(from)[0]=(double) c_from; + PROTECT(to=NEW_NUMERIC(1)); + REAL(to)[0]=(double) 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); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_consensus / +/ igraph_pseudo_diameter_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_hrg_consensus(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples) { +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_parents; igraph_vector_t c_weights; - igraph_hrg_t c_hrg; - igraph_bool_t c_start; - int c_num_samples; - SEXP parents; - SEXP weights; + 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_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)) { - 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]; + 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_hrg_consensus(&c_graph, &c_parents, &c_weights, &c_hrg, c_start, c_num_samples)); + 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(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); - 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_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; - - SEXP r_result, r_names; - /* 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]; - /* 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_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")); + PROTECT(diameter=NEW_NUMERIC(1)); + REAL(diameter)[0]=c_diameter; + PROTECT(from=NEW_NUMERIC(1)); + REAL(from)[0]=(double) c_from; + PROTECT(to=NEW_NUMERIC(1)); + REAL(to)[0]=(double) 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); @@ -4979,75 +5210,89 @@ SEXP R_igraph_hrg_predict(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples, SE } /*-------------------------------------------/ -/ igraph_hrg_create / +/ igraph_diversity / /-------------------------------------------*/ -SEXP R_igraph_hrg_create(SEXP graph, SEXP prob) { +SEXP R_igraph_diversity(SEXP graph, SEXP weights, SEXP vids) { /* Declarations */ - igraph_hrg_t c_hrg; igraph_t c_graph; - igraph_vector_t c_prob; - SEXP hrg; + igraph_vector_t c_weights; + igraph_vector_t c_res; + igraph_vs_t c_vids; + SEXP res; SEXP r_result; /* Convert input */ - if (0 != igraph_hrg_init(&c_hrg, 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_hrg_destroy, &c_hrg); - R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(prob, &c_prob); + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_create(&c_hrg, &c_graph, &c_prob)); + IGRAPH_R_CHECK(igraph_diversity(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_vids)); /* Convert output */ - 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); - r_result = hrg; + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_infomap / +/ igraph_random_walk / /-------------------------------------------*/ -SEXP R_igraph_community_infomap(SEXP graph, SEXP e_weights, SEXP v_weights, SEXP nb_trials) { +SEXP R_igraph_random_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { /* 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_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, 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_init(&c_membership, 0)) { + 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_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); + 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=(igraph_integer_t) REAL(steps)[0]; + c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); /* 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_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(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(vertices=R_igraph_vector_int_to_SEXPp1(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); 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")); + PROTECT(edges=R_igraph_vector_int_to_SEXPp1(&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); @@ -5056,87 +5301,106 @@ SEXP R_igraph_community_infomap(SEXP graph, SEXP e_weights, SEXP v_weights, SEXP } /*-------------------------------------------/ -/ igraph_to_directed / +/ igraph_random_edge_walk / /-------------------------------------------*/ -SEXP R_igraph_to_directed(SEXP graph, SEXP mode) { +SEXP R_igraph_random_edge_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { /* Declarations */ igraph_t c_graph; - igraph_to_directed_t c_mode; + 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_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_mode = (igraph_to_directed_t) Rf_asInteger(mode); + 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=(igraph_integer_t) REAL(steps)[0]; + c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_directed(&c_graph, c_mode)); + 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 */ - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); + PROTECT(edgewalk=R_igraph_vector_int_to_SEXPp1(&c_edgewalk)); + igraph_vector_int_destroy(&c_edgewalk); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = edgewalk; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_to_undirected / +/ igraph_global_efficiency / /-------------------------------------------*/ -SEXP R_igraph_to_undirected(SEXP graph, SEXP mode, SEXP edge_attr_comb) { +SEXP R_igraph_global_efficiency(SEXP graph, SEXP weights, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_to_undirected_t c_mode; - igraph_attribute_combination_t c_edge_attr_comb; + 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_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); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_undirected(&c_graph, c_mode, &c_edge_attr_comb)); + IGRAPH_R_CHECK(igraph_global_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed)); /* Convert output */ - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - igraph_attribute_combination_destroy(&c_edge_attr_comb); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_stochastic / +/ igraph_local_efficiency / /-------------------------------------------*/ -SEXP R_igraph_get_stochastic(SEXP graph, SEXP column_wise) { +SEXP R_igraph_local_efficiency(SEXP graph, SEXP vids, SEXP weights, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_bool_t c_column_wise; + 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; 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_column_wise=LOGICAL(column_wise)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_stochastic(&c_graph, &c_res, c_column_wise)); + 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(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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); r_result = res; UNPROTECT(1); @@ -5144,131 +5408,123 @@ SEXP R_igraph_get_stochastic(SEXP graph, SEXP column_wise) { } /*-------------------------------------------/ -/ igraph_get_stochastic_sparsemat / +/ igraph_average_local_efficiency / /-------------------------------------------*/ -SEXP R_igraph_get_stochastic_sparsemat(SEXP graph, SEXP column_wise) { +SEXP R_igraph_average_local_efficiency(SEXP graph, SEXP weights, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_sparsemat_t c_sparsemat; - igraph_bool_t c_column_wise; - SEXP sparsemat; + 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; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - /* Don't need to init. */ - c_column_wise=LOGICAL(column_wise)[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_get_stochastic_sparsemat(&c_graph, &c_sparsemat, c_column_wise)); + IGRAPH_R_CHECK(igraph_average_local_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); /* Convert output */ - PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); - igraph_sparsemat_destroy(&c_sparsemat); - r_result = sparsemat; + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_dyad_census / +/ igraph_transitive_closure_dag / /-------------------------------------------*/ -SEXP R_igraph_dyad_census(SEXP graph) { +SEXP R_igraph_transitive_closure_dag(SEXP graph) { /* 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_t c_closure; + SEXP closure; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_mut=0; - c_asym=0; - c_null=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_dyad_census(&c_graph, &c_mut, &c_asym, &c_null)); + IGRAPH_R_CHECK(igraph_transitive_closure_dag(&c_graph, &c_closure)); /* 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")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + IGRAPH_FINALLY(igraph_destroy, &c_closure); + PROTECT(closure=R_igraph_to_SEXP(&c_closure)); + IGRAPH_I_DESTROY(&c_closure); + IGRAPH_FINALLY_CLEAN(1); + r_result = closure; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_triad_census / +/ igraph_trussness / /-------------------------------------------*/ -SEXP R_igraph_triad_census(SEXP graph) { +SEXP R_igraph_trussness(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - SEXP res; + igraph_vector_int_t c_trussness; + SEXP trussness; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_int_init(&c_trussness, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_trussness); /* Call igraph */ - IGRAPH_R_CHECK(igraph_triad_census(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_trussness(&c_graph, &c_trussness)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(trussness=R_igraph_vector_int_to_SEXP(&c_trussness)); + igraph_vector_int_destroy(&c_trussness); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = trussness; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_adjacent_triangles / +/ igraph_is_graphical / /-------------------------------------------*/ -SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) { +SEXP R_igraph_is_graphical(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types) { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_res; - igraph_vs_t c_vids; + 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(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + R_SEXP_to_vector_int_copy(out_deg, &c_out_deg); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_out_deg); + if (!Rf_isNull(in_deg)) { + R_SEXP_to_vector_int_copy(in_deg, &c_in_deg); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_in_deg); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_in_deg, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_in_deg); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); + c_allowed_edge_types = (igraph_edge_type_sw_t) Rf_asInteger(allowed_edge_types); /* Call igraph */ - IGRAPH_R_CHECK(igraph_adjacent_triangles(&c_graph, &c_res, c_vids)); + IGRAPH_R_CHECK(igraph_is_graphical(&c_out_deg, (Rf_isNull(in_deg) ? 0 : &c_in_deg), c_allowed_edge_types, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + igraph_vector_int_destroy(&c_out_deg); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); + igraph_vector_int_destroy(&c_in_deg); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -5276,615 +5532,624 @@ SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) { } /*-------------------------------------------/ -/ igraph_local_scan_0 / +/ igraph_bfs_simple / /-------------------------------------------*/ -SEXP R_igraph_local_scan_0(SEXP graph, SEXP weights, SEXP mode) { +SEXP R_igraph_bfs_simple(SEXP graph, SEXP root, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_weights; + igraph_integer_t c_root; igraph_neimode_t c_mode; - SEXP res; + 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(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + 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_destroy, &c_res); - 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_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_local_scan_0(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_bfs_simple(&c_graph, c_root, c_mode, &c_order, &c_layers, &c_parents)); /* 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(order=R_igraph_vector_int_to_SEXPp1(&c_order)); + igraph_vector_int_destroy(&c_order); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(layers=R_igraph_vector_int_to_SEXP(&c_layers)); + igraph_vector_int_destroy(&c_layers); + IGRAPH_FINALLY_CLEAN(1); + 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_local_scan_0_them / +/ igraph_bipartite_projection_size / /-------------------------------------------*/ -SEXP R_igraph_local_scan_0_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode) { +SEXP R_igraph_bipartite_projection_size(SEXP graph, SEXP types) { /* 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; + 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; - 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)) { - 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); + 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; /* 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_projection_size(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_vcount1, &c_ecount1, &c_vcount2, &c_ecount2)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_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_NUMERIC(1)); + REAL(vcount1)[0]=(double) c_vcount1; + PROTECT(ecount1=NEW_NUMERIC(1)); + REAL(ecount1)[0]=(double) c_ecount1; + PROTECT(vcount2=NEW_NUMERIC(1)); + REAL(vcount2)[0]=(double) c_vcount2; + PROTECT(ecount2=NEW_NUMERIC(1)); + REAL(ecount2)[0]=(double) 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_local_scan_1_ecount / +/ igraph_create_bipartite / /-------------------------------------------*/ -SEXP R_igraph_local_scan_1_ecount(SEXP graph, SEXP weights, SEXP mode) { +SEXP R_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_weights; - igraph_neimode_t c_mode; - SEXP res; + 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); - 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); + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + R_SEXP_to_vector_int_copy(edges, &c_edges); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_directed=LOGICAL(directed)[0]; /* 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_create_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_edges, 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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_1_ecount_them / +/ igraph_biadjacency / /-------------------------------------------*/ -SEXP R_igraph_local_scan_1_ecount_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode) { +SEXP R_igraph_biadjacency(SEXP incidence, SEXP directed, SEXP mode, SEXP multiple) { /* 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_matrix_t c_incidence; + igraph_bool_t c_directed; igraph_neimode_t c_mode; - SEXP res; + igraph_bool_t c_multiple; + 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); + 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_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_biadjacency(&c_graph, &c_types, &c_incidence, c_directed, c_mode, c_multiple)); /* 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_I_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_k_ecount / +/ igraph_get_biadjacency / /-------------------------------------------*/ -SEXP R_igraph_local_scan_k_ecount(SEXP graph, SEXP k, SEXP weights, SEXP mode) { +SEXP R_igraph_get_biadjacency(SEXP graph, SEXP types) { /* Declarations */ igraph_t c_graph; - int c_k; - igraph_vector_t c_res; - igraph_vector_t c_weights; - igraph_neimode_t c_mode; + 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); - c_k=INTEGER(k)[0]; - 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); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + 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_local_scan_k_ecount(&c_graph, c_k, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + 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_SEXPp1(&c_row_ids)); + igraph_vector_int_destroy(&c_row_ids); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(col_ids=R_igraph_vector_int_to_SEXPp1(&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_local_scan_k_ecount_them / +/ igraph_is_bipartite / /-------------------------------------------*/ -SEXP R_igraph_local_scan_k_ecount_them(SEXP us, SEXP them, SEXP k, SEXP weights_them, SEXP mode) { +SEXP R_igraph_is_bipartite(SEXP graph) { /* 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; + igraph_t c_graph; + 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(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_bool_init(&c_type, 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_bool_destroy, &c_type); /* 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_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); - 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_neighborhood_ecount / +/ igraph_bipartite_game_gnp / /-------------------------------------------*/ -SEXP R_igraph_local_scan_neighborhood_ecount(SEXP graph, SEXP weights, SEXP neighborhoods) { +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_ptr_t c_neighborhoods; - SEXP res; + 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; - 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); } - if (!Rf_isNull(neighborhoods)) { R_igraph_SEXP_to_vectorlist_int(neighborhoods, &c_neighborhoods); } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_n1=(igraph_integer_t) REAL(n1)[0]; + c_n2=(igraph_integer_t) REAL(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_neighborhood_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), &c_neighborhoods)); + 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_I_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_list_triangles / +/ igraph_bipartite_game_gnm / /-------------------------------------------*/ -SEXP R_igraph_list_triangles(SEXP graph) { +SEXP R_igraph_bipartite_game_gnm(SEXP n1, SEXP n2, SEXP m, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_res; - SEXP res; + 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; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { + if (0 != igraph_vector_bool_init(&c_types, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_n1=(igraph_integer_t) REAL(n1)[0]; + c_n2=(igraph_integer_t) REAL(n2)[0]; + c_m=(igraph_integer_t) REAL(m)[0]; + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_list_triangles(&c_graph, &c_res)); + 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_int_to_SEXPp1(&c_res)); - igraph_vector_int_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_I_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_maxflow / +/ igraph_bipartite_game / /-------------------------------------------*/ -SEXP R_igraph_maxflow(SEXP graph, SEXP source, SEXP target, SEXP capacity) { +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_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_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 graph; + SEXP types; 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); - flow=R_GlobalEnv; /* hack to have a non-NULL value */ - 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_bool_init(&c_types, 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_bool_destroy, &c_types); + c_type = (igraph_erdos_renyi_t) Rf_asInteger(type); + c_n1=(igraph_integer_t) REAL(n1)[0]; + c_n2=(igraph_integer_t) REAL(n2)[0]; + c_p=REAL(p)[0]; + c_m=(igraph_integer_t) REAL(m)[0]; + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* 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_bipartite_game(&c_graph, &c_types, c_type, c_n1, c_n2, c_p, c_m, c_directed, c_mode)); /* 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); - IGRAPH_FINALLY_CLEAN(1); - 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); + 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_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition2=R_igraph_vector_to_SEXPp1(&c_partition2)); - igraph_vector_destroy(&c_partition2); + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); 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, 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(7); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_st_mincut / +/ igraph_get_laplacian / /-------------------------------------------*/ -SEXP R_igraph_st_mincut(SEXP graph, SEXP source, SEXP target, SEXP capacity) { +SEXP R_igraph_get_laplacian(SEXP graph, SEXP mode, SEXP normalization, SEXP weights) { /* 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_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, 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_matrix_init(&c_res, 0, 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_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_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_get_laplacian(&c_graph, &c_res, c_mode, c_normalization, (Rf_isNull(weights) ? 0 : &c_weights))); /* 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_matrix_to_SEXP(&c_res)); + igraph_matrix_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_get_laplacian_sparse / /-------------------------------------------*/ -SEXP R_igraph_dominator_tree(SEXP graph, SEXP root, SEXP mode) { +SEXP R_igraph_get_laplacian_sparse(SEXP graph, SEXP mode, SEXP normalization, SEXP weights) { /* 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_sparsemat_t c_sparseres; igraph_neimode_t c_mode; - SEXP dom; - SEXP domtree; - SEXP leftout; + igraph_laplacian_normalization_t c_normalization; + igraph_vector_t c_weights; + SEXP sparseres; - 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_sparsemat_init(&c_sparseres, 0, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_leftout); + 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_dominator_tree(&c_graph, c_root, &c_dom, (Rf_isNull(domtree) ? 0 : &c_domtree), &c_leftout, 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(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_I_DESTROY(&c_domtree); + PROTECT(sparseres=R_igraph_sparsemat_to_SEXP(&c_sparseres)); + igraph_sparsemat_destroy(&c_sparseres); 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 = sparseres; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_all_st_cuts / +/ igraph_connected_components / /-------------------------------------------*/ -SEXP R_igraph_all_st_cuts(SEXP graph, SEXP source, SEXP target) { +SEXP R_igraph_connected_components(SEXP graph, SEXP mode) { /* 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_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, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_cuts, 0)) { + if (0 != igraph_vector_int_init(&c_membership, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_cuts); - if (0 != igraph_vector_ptr_init(&c_partition1s, 0)) { + 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(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_int_destroy, &c_csize); + c_no=0; + c_mode=REAL(mode)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_all_st_cuts(&c_graph, &c_cuts, &c_partition1s, c_source, c_target)); + IGRAPH_R_CHECK(igraph_connected_components(&c_graph, &c_membership, &c_csize, &c_no, c_mode)); /* 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); + 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(partition1s=R_igraph_vectorlist_to_SEXP_p1(&c_partition1s)); - R_igraph_vectorlist_destroy(&c_partition1s); + PROTECT(csize=R_igraph_vector_int_to_SEXP(&c_csize)); + igraph_vector_int_destroy(&c_csize); 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")); + PROTECT(no=NEW_NUMERIC(1)); + REAL(no)[0]=(double) 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(3); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_all_st_mincuts / +/ igraph_is_connected / /-------------------------------------------*/ -SEXP R_igraph_all_st_mincuts(SEXP graph, SEXP source, SEXP target, SEXP capacity) { +SEXP R_igraph_is_connected(SEXP graph, SEXP mode) { /* 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_bool_t c_res; + igraph_connectedness_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_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)) { - 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); } + c_mode=REAL(mode)[0]; /* 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_is_connected(&c_graph, &c_res, c_mode)); /* 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); - 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); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_separator / +/ igraph_articulation_points / /-------------------------------------------*/ -SEXP R_igraph_is_separator(SEXP graph, SEXP candidate) { +SEXP R_igraph_articulation_points(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vs_t c_candidate; - igraph_bool_t c_res; + igraph_vector_int_t c_res; SEXP res; 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_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_is_separator(&c_graph, c_candidate, &c_res)); + IGRAPH_R_CHECK(igraph_articulation_points(&c_graph, &c_res)); /* Convert output */ - igraph_vs_destroy(&c_candidate); - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; + PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); + igraph_vector_int_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -5892,515 +6157,4774 @@ SEXP R_igraph_is_separator(SEXP graph, SEXP candidate) { } /*-------------------------------------------/ -/ igraph_is_minimal_separator / +/ igraph_biconnected_components / /-------------------------------------------*/ -SEXP R_igraph_is_minimal_separator(SEXP graph, SEXP candidate) { +SEXP R_igraph_biconnected_components(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vs_t c_candidate; - igraph_bool_t c_res; - SEXP res; + 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; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_igraph_vs(candidate, &c_graph, &c_candidate); + c_no=0; + if (0 != igraph_vector_int_list_init(&c_tree_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + 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_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_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_int_destroy, &c_articulation_points); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_minimal_separator(&c_graph, c_candidate, &c_res)); + IGRAPH_R_CHECK(igraph_biconnected_components(&c_graph, &c_no, &c_tree_edges, &c_component_edges, &c_components, &c_articulation_points)); /* 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(5)); + PROTECT(r_names=NEW_CHARACTER(5)); + PROTECT(no=NEW_NUMERIC(1)); + REAL(no)[0]=(double) c_no; + PROTECT(tree_edges=R_igraph_vector_int_list_to_SEXPp1(&c_tree_edges)); + igraph_vector_int_list_destroy(&c_tree_edges); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(component_edges=R_igraph_vector_int_list_to_SEXPp1(&c_component_edges)); + igraph_vector_int_list_destroy(&c_component_edges); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(components=R_igraph_vector_int_list_to_SEXPp1(&c_components)); + igraph_vector_int_list_destroy(&c_components); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(articulation_points=R_igraph_vector_int_to_SEXPp1(&c_articulation_points)); + igraph_vector_int_destroy(&c_articulation_points); + 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); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_all_minimal_st_separators / +/ igraph_bridges / /-------------------------------------------*/ -SEXP R_igraph_all_minimal_st_separators(SEXP graph) { +SEXP R_igraph_bridges(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_separators; - SEXP separators; + igraph_vector_int_t c_res; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_separators, 0)) { + if (0 != igraph_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_separators); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_all_minimal_st_separators(&c_graph, &c_separators)); + IGRAPH_R_CHECK(igraph_bridges(&c_graph, &c_res)); /* Convert output */ - PROTECT(separators=R_igraph_vectorlist_to_SEXP_p1(&c_separators)); - R_igraph_vectorlist_destroy(&c_separators); + PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = separators; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_minimum_size_separators / +/ igraph_cliques / /-------------------------------------------*/ -SEXP R_igraph_minimum_size_separators(SEXP graph) { +SEXP R_igraph_cliques(SEXP graph, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_separators; - SEXP separators; + igraph_vector_int_list_t c_res; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_separators, 0)) { + 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_size=(igraph_integer_t) REAL(min_size)[0]; + c_max_size=(igraph_integer_t) REAL(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_minimum_size_separators(&c_graph, &c_separators)); + IGRAPH_R_CHECK(igraph_cliques(&c_graph, &c_res, c_min_size, c_max_size)); /* 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_SEXPp1(&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_clique_size_hist / /-------------------------------------------*/ -SEXP R_igraph_isoclass(SEXP graph) { +SEXP R_igraph_clique_size_hist(SEXP graph, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_isoclass; - SEXP isoclass; + 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); - c_isoclass=0; + if (0 != igraph_vector_init(&c_hist, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); + c_min_size=(igraph_integer_t) REAL(min_size)[0]; + c_max_size=(igraph_integer_t) REAL(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_isoclass(&c_graph, &c_isoclass)); + IGRAPH_R_CHECK(igraph_clique_size_hist(&c_graph, &c_hist, c_min_size, c_max_size)); /* Convert output */ - PROTECT(isoclass=NEW_INTEGER(1)); - INTEGER(isoclass)[0]=c_isoclass; - r_result = isoclass; + 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_isomorphic / +/ igraph_largest_cliques / /-------------------------------------------*/ -SEXP R_igraph_isomorphic(SEXP graph1, SEXP graph2) { +SEXP R_igraph_largest_cliques(SEXP graph) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_bool_t c_iso; - SEXP iso; + igraph_t c_graph; + igraph_vector_int_list_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 (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_isomorphic(&c_graph1, &c_graph2, &c_iso)); + IGRAPH_R_CHECK(igraph_largest_cliques(&c_graph, &c_res)); /* Convert output */ - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - r_result = iso; + PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isoclass_subgraph / +/ igraph_maximal_cliques_subset / /-------------------------------------------*/ -SEXP R_igraph_isoclass_subgraph(SEXP graph, SEXP vids) { +SEXP R_igraph_maximal_cliques_subset(SEXP graph, SEXP subset, SEXP outfile, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vids; - igraph_integer_t c_isoclass; - SEXP isoclass; + 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_vector(vids, &c_vids); - c_isoclass=0; + R_SEXP_to_vector_int_copy(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=(igraph_integer_t) REAL(min_size)[0]; + c_max_size=(igraph_integer_t) REAL(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_isoclass_subgraph(&c_graph, &c_vids, &c_isoclass)); + 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 */ - PROTECT(isoclass=NEW_INTEGER(1)); - INTEGER(isoclass)[0]=c_isoclass; - r_result = isoclass; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(no=NEW_NUMERIC(1)); + REAL(no)[0]=(double) 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_isoclass_create / +/ igraph_maximal_cliques_hist / /-------------------------------------------*/ -SEXP R_igraph_isoclass_create(SEXP size, SEXP number, SEXP directed) { +SEXP R_igraph_maximal_cliques_hist(SEXP graph, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_size; - igraph_integer_t c_number; - igraph_bool_t c_directed; - SEXP graph; + igraph_vector_t c_hist; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; + SEXP hist; 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_vector_init(&c_hist, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); + c_min_size=(igraph_integer_t) REAL(min_size)[0]; + c_max_size=(igraph_integer_t) REAL(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_isoclass_create(&c_graph, c_size, c_number, c_directed)); + IGRAPH_R_CHECK(igraph_maximal_cliques_hist(&c_graph, &c_hist, c_min_size, c_max_size)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); + PROTECT(hist=R_igraph_vector_to_SEXP(&c_hist)); + igraph_vector_destroy(&c_hist); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = hist; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isomorphic_vf2 / +/ igraph_clique_number / /-------------------------------------------*/ -SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_clique_number(SEXP graph) { /* 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_integer_t c_no; + SEXP no; + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_no=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_clique_number(&c_graph, &c_no)); + + /* Convert output */ + PROTECT(no=NEW_NUMERIC(1)); + REAL(no)[0]=(double) c_no; + r_result = no; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_weighted_cliques / +/-------------------------------------------*/ +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_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 (!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); + 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_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(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_largest_weighted_cliques / +/-------------------------------------------*/ +SEXP R_igraph_largest_weighted_cliques(SEXP graph, SEXP vertex_weights) { + /* Declarations */ + igraph_t c_graph; + 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); + 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_largest_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_weighted_clique_number / +/-------------------------------------------*/ +SEXP R_igraph_weighted_clique_number(SEXP graph, SEXP vertex_weights) { + /* Declarations */ + 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(graph, &c_graph); + if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_weighted_clique_number(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_star / +/-------------------------------------------*/ +SEXP R_igraph_layout_star(SEXP graph, SEXP center, SEXP order) { + /* Declarations */ + igraph_t c_graph; + 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); + 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]; + if (!Rf_isNull(order)) { + R_SEXP_to_vector_int_copy(order, &c_order); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_order); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_order, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_order); + } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_star(&c_graph, &c_res, c_center, (Rf_isNull(order) ? 0 : &c_order))); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_order); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_grid / +/-------------------------------------------*/ +SEXP R_igraph_layout_grid(SEXP graph, SEXP width) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_integer_t c_width; + 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=(igraph_integer_t) REAL(width)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_grid(&c_graph, &c_res, c_width)); + + /* 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_grid_3d / +/-------------------------------------------*/ +SEXP R_igraph_layout_grid_3d(SEXP graph, SEXP width, SEXP height) { + /* Declarations */ + 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=(igraph_integer_t) REAL(width)[0]; + c_height=(igraph_integer_t) REAL(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_SEXPp1(&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 : (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 : (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); + if (!Rf_isNull(layers)) { + R_SEXP_to_vector_int_copy(layers, &c_layers); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_layers); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_layers, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_layers); + } + c_hgap=REAL(hgap)[0]; + c_vgap=REAL(vgap)[0]; + c_maxiter=(igraph_integer_t) REAL(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, (Rf_isNull(layers) ? 0 : &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_I_DESTROY(&c_extd_graph); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(extd_to_orig_eids=R_igraph_vector_int_to_SEXPp1(&c_extd_to_orig_eids)); + igraph_vector_int_destroy(&c_extd_to_orig_eids); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_layers); + 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); + if (!Rf_isNull(dist)) { R_SEXP_to_matrix(dist, &c_dist); } + c_dim=(igraph_integer_t) REAL(dim)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_mds(&c_graph, &c_res, (Rf_isNull(dist) ? 0 : &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=(igraph_integer_t) REAL(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=(igraph_integer_t) REAL(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=(igraph_integer_t) REAL(maxiter)[0]; + c_fineiter=(igraph_integer_t) REAL(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]; + if (!Rf_isNull(distances)) { + R_SEXP_to_vector(distances, &c_distances); + } + c_min_dist=REAL(min_dist)[0]; + c_epochs=(igraph_integer_t) REAL(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, (Rf_isNull(distances) ? 0 : &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]; + if (!Rf_isNull(distances)) { + R_SEXP_to_vector(distances, &c_distances); + } + c_min_dist=REAL(min_dist)[0]; + c_epochs=(igraph_integer_t) REAL(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, (Rf_isNull(distances) ? 0 : &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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + 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); + igraph_vector_int_t c_es_data; + R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + 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); + igraph_vector_int_destroy(&c_es_data); + igraph_es_destroy(&c_es); + 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_copy(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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + 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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + 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); + igraph_vector_int_t c_es_data; + R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + 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); + igraph_vector_int_destroy(&c_es_data); + igraph_es_destroy(&c_es); + 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_copy(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_copy(comm1, &c_comm1); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_comm1); + R_SEXP_to_vector_int_copy(comm2, &c_comm2); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 */ + igraph_vector_int_destroy(&c_comm1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_comm2); + IGRAPH_FINALLY_CLEAN(1); + 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_copy(membership, &c_membership); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (Rf_isNull(weights) ? 0 : &c_weights)), c_resolution, c_directed, &c_modularity)); + + /* Convert output */ + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + 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 : (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=(igraph_integer_t) REAL(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); } + if (!Rf_isNull(initial)) { + R_SEXP_to_vector_int_copy(initial, &c_initial); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_initial); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_initial, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_initial); + } + if (!Rf_isNull(fixed)) { + 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 : (Rf_isNull(weights) ? 0 : &c_weights)), (Rf_isNull(initial) ? 0 : &c_initial), (Rf_isNull(fixed) ? 0 : &c_fixed))); + + /* Convert output */ + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_initial); + 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 : (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 : (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=(igraph_integer_t) REAL(n_iterations)[0]; + if (!Rf_isNull(membership)) { + R_SEXP_to_vector_int_copy(membership, &c_membership); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + } + c_nb_clusters=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_leiden(&c_graph, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), (Rf_isNull(vertex_weights) ? 0 : (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_NUMERIC(1)); + REAL(nb_clusters)[0]=(double) 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_copy(comm1, &c_comm1); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_comm1); + R_SEXP_to_vector_int_copy(comm2, &c_comm2); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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)); + igraph_vector_int_destroy(&c_comm1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_comm2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(distance12=NEW_NUMERIC(1)); + REAL(distance12)[0]=(double) c_distance12; + PROTECT(distance21=NEW_NUMERIC(1)); + REAL(distance21)[0]=(double) 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=(igraph_integer_t) REAL(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=(igraph_integer_t) REAL(steps)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_fit(&c_graph, &c_hrg, c_start, c_steps)); + + /* Convert output */ + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + r_result = hrg; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_sample / +/-------------------------------------------*/ +SEXP R_igraph_hrg_sample(SEXP hrg) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_t c_sample; + SEXP sample; + + SEXP r_result; + /* Convert input */ + 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_I_DESTROY(&c_sample); + IGRAPH_FINALLY_CLEAN(1); + r_result = sample; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_sample_many / +/-------------------------------------------*/ +SEXP R_igraph_hrg_sample_many(SEXP hrg, SEXP num_samples) { + /* Declarations */ + 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=(igraph_integer_t) REAL(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_FREE(c_samples.stor_begin); + 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_I_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=(igraph_integer_t) REAL(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=(igraph_integer_t) REAL(num_samples)[0]; + c_num_bins=(igraph_integer_t) REAL(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_SEXPp1(&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=(igraph_integer_t) REAL(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_NUMERIC(1)); + REAL(r_result)[0]=(double) c_result; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_from_hrg_dendrogram / +/-------------------------------------------*/ +SEXP R_igraph_from_hrg_dendrogram(SEXP hrg) { + /* Declarations */ + igraph_t c_graph; + igraph_hrg_t c_hrg; + igraph_vector_t c_prob; + SEXP graph; + SEXP prob; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_hrg(hrg, &c_hrg); + if (0 != igraph_vector_init(&c_prob, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_prob); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_from_hrg_dendrogram(&c_graph, &c_hrg, &c_prob)); + + /* 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_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(prob=R_igraph_vector_to_SEXP(&c_prob)); + igraph_vector_destroy(&c_prob); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, prob); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("prob")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + 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_I_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_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_attribute_combination_destroy(&c_edge_attr_comb); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_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_I_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_NUMERIC(1)); + REAL(source)[0]=(double) c_source; + PROTECT(target=NEW_NUMERIC(1)); + REAL(target)[0]=(double) 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_I_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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_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); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + 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=(igraph_integer_t) REAL(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=(igraph_integer_t) REAL(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); } + R_igraph_SEXP_to_vector_int_list(neighborhoods, &c_neighborhoods); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &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); + igraph_vector_int_list_destroy(&c_neighborhoods); + 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); } + R_igraph_SEXP_to_vector_int_list(subsets, &c_subsets); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &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); + igraph_vector_int_list_destroy(&c_subsets); + 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_SEXPp1(&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); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + 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_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + PROTECT(map=R_igraph_vector_int_to_SEXPp1(&c_map)); + igraph_vector_int_destroy(&c_map); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(invmap=R_igraph_vector_int_to_SEXPp1(&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 : (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_I_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 : (Rf_isNull(capacity) ? 0 : &c_capacity)), &c_stats)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(6)); + PROTECT(r_names=NEW_CHARACTER(6)); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(flow=R_igraph_vector_to_SEXP(&c_flow)); + igraph_vector_destroy(&c_flow); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(cut=R_igraph_vector_int_to_SEXPp1(&c_cut)); + igraph_vector_int_destroy(&c_cut); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1=R_igraph_vector_int_to_SEXPp1(&c_partition1)); + igraph_vector_int_destroy(&c_partition1); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition2=R_igraph_vector_int_to_SEXPp1(&c_partition2)); + igraph_vector_int_destroy(&c_partition2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(stats=R_igraph_maxflow_stats_to_SEXP(&c_stats)); + SET_VECTOR_ELT(r_result, 0, value); + SET_VECTOR_ELT(r_result, 1, flow); + SET_VECTOR_ELT(r_result, 2, cut); + SET_VECTOR_ELT(r_result, 3, partition1); + SET_VECTOR_ELT(r_result, 4, partition2); + SET_VECTOR_ELT(r_result, 5, stats); + SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("flow")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("cut")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("partition1")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("partition2")); + SET_STRING_ELT(r_names, 5, Rf_mkChar("stats")); + SET_NAMES(r_result, r_names); + UNPROTECT(7); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_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_I_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_I_DESTROY(&c_residual); + IGRAPH_FINALLY_CLEAN(1); + r_result = residual; + + 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 : (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_SEXPp1(&c_cut)); + igraph_vector_int_destroy(&c_cut); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1=R_igraph_vector_int_to_SEXPp1(&c_partition1)); + igraph_vector_int_destroy(&c_partition1); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition2=R_igraph_vector_int_to_SEXPp1(&c_partition2)); + igraph_vector_int_destroy(&c_partition2); + IGRAPH_FINALLY_CLEAN(1); + 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_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_SEXPp1(&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_I_DESTROY(&c_domtree); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(leftout=R_igraph_vector_int_to_SEXPp1(&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_SEXPp1(&c_cuts)); + igraph_vector_int_list_destroy(&c_cuts); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1s=R_igraph_vector_int_list_to_SEXPp1(&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 : (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_SEXPp1(&c_cuts)); + igraph_vector_int_list_destroy(&c_cuts); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1s=R_igraph_vector_int_list_to_SEXPp1(&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_I_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); + igraph_vector_int_t c_candidate_data; + R_SEXP_to_igraph_vs(candidate, &c_graph, &c_candidate, &c_candidate_data); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_separator(&c_graph, c_candidate, &c_res)); + + /* Convert output */ + igraph_vector_int_destroy(&c_candidate_data); + igraph_vs_destroy(&c_candidate); + 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); + igraph_vector_int_t c_candidate_data; + R_SEXP_to_igraph_vs(candidate, &c_graph, &c_candidate, &c_candidate_data); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_minimal_separator(&c_graph, c_candidate, &c_res)); + + /* Convert output */ + igraph_vector_int_destroy(&c_candidate_data); + igraph_vs_destroy(&c_candidate); + 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_SEXPp1(&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_SEXPp1(&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_NUMERIC(1)); + REAL(isoclass)[0]=(double) 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_copy(vids, &c_vids); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vids); + c_isoclass=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isoclass_subgraph(&c_graph, &c_vids, &c_isoclass)); + + /* Convert output */ + igraph_vector_int_destroy(&c_vids); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(isoclass=NEW_NUMERIC(1)); + REAL(isoclass)[0]=(double) 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=(igraph_integer_t) REAL(size)[0]; + c_number=(igraph_integer_t) REAL(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_I_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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1)), (Rf_isNull(vertex_color2) ? 0 : (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2)), (Rf_isNull(edge_color1) ? 0 : (Rf_isNull(edge_color1) ? 0 : &c_edge_color1)), (Rf_isNull(edge_color2) ? 0 : (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)); + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + PROTECT(map12=R_igraph_vector_int_to_SEXPp1(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXPp1(&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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(count=NEW_NUMERIC(1)); + REAL(count)[0]=(double) 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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + 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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1)), (Rf_isNull(vertex_color2) ? 0 : (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2)), (Rf_isNull(edge_color1) ? 0 : (Rf_isNull(edge_color1) ? 0 : &c_edge_color1)), (Rf_isNull(edge_color2) ? 0 : (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)); + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + PROTECT(map12=R_igraph_vector_int_to_SEXPp1(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXPp1(&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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1)), (Rf_isNull(vertex_color2) ? 0 : (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2)), (Rf_isNull(edge_color1) ? 0 : (Rf_isNull(edge_color1) ? 0 : &c_edge_color1)), (Rf_isNull(edge_color2) ? 0 : (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)); + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map12=R_igraph_vector_int_to_SEXPp1(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXPp1(&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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(count=NEW_NUMERIC(1)); + REAL(count)[0]=(double) 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_copy(vertex_color1, &c_vertex_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); + if (!Rf_isNull(vertex_color2)) { + R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); + if (!Rf_isNull(edge_color1)) { + R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); + if (!Rf_isNull(edge_color2)) { + R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 */ + igraph_vector_int_destroy(&c_vertex_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertex_color2); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edge_color2); + IGRAPH_FINALLY_CLEAN(1); + 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_copy(colors, &c_colors); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (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)); + igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(labeling=R_igraph_vector_int_to_SEXPp1(&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_copy(permutation, &c_permutation); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_permutation); + 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_copy(colors1, &c_colors1); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors1, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors1); + if (!Rf_isNull(colors2)) { + R_SEXP_to_vector_int_copy(colors2, &c_colors2); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors2, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (Rf_isNull(colors1) ? 0 : &c_colors1)), (Rf_isNull(colors2) ? 0 : (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)); + igraph_vector_int_destroy(&c_colors1); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_colors2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + PROTECT(map12=R_igraph_vector_int_to_SEXPp1(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXPp1(&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_copy(colors, &c_colors); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); + c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : (Rf_isNull(colors) ? 0 : &c_colors)), c_sh, &c_info)); + + /* Convert output */ + igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY_CLEAN(1); + 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_copy(colors, &c_colors); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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 : (Rf_isNull(colors) ? 0 : &c_colors)), &c_generators, c_sh, &c_info)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(generators=R_igraph_vector_int_list_to_SEXPp1(&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(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_I_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=(igraph_integer_t) REAL(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_NUMERIC(1)); + REAL(count)[0]=(double) 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_copy(matching, &c_matching); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_matching); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_matching(&c_graph, (Rf_isNull(types) ? 0 : (Rf_isNull(types) ? 0 : &c_types)), &c_matching, &c_res)); + + /* Convert output */ + igraph_vector_int_destroy(&c_matching); + IGRAPH_FINALLY_CLEAN(1); + 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_copy(matching, &c_matching); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_matching); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_maximal_matching(&c_graph, (Rf_isNull(types) ? 0 : (Rf_isNull(types) ? 0 : &c_types)), &c_matching, &c_res)); + + /* Convert output */ + igraph_vector_int_destroy(&c_matching); + IGRAPH_FINALLY_CLEAN(1); + 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 : (Rf_isNull(types) ? 0 : &c_types)), &c_matching_size, &c_matching_weight, &c_matching, (Rf_isNull(weights) ? 0 : (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_NUMERIC(1)); + REAL(matching_size)[0]=(double) c_matching_size; + PROTECT(matching_weight=NEW_NUMERIC(1)); + REAL(matching_weight)[0]=c_matching_weight; + PROTECT(matching=R_igraph_vector_int_to_SEXPp1(&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(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); - if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); - if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + 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_int_destroy, &c_edge_color1); - if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + 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_int_destroy, &c_edge_color2); - if (0 != igraph_vector_init(&c_map12, 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_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_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)); - igraph_vector_int_destroy(&c_vertex_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_vertex_color2); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color1); + 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); - igraph_vector_int_destroy(&c_edge_color2); + PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); + igraph_matrix_destroy(&c_vectors); IGRAPH_FINALLY_CLEAN(1); - 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(cmplxvalues=R_igraph_0orvector_complex_to_SEXP(&c_cmplxvalues)); + igraph_vector_complex_destroy(&c_cmplxvalues); IGRAPH_FINALLY_CLEAN(1); - PROTECT(map21=R_igraph_0orvector_to_SEXPp1(&c_map21)); - igraph_vector_destroy(&c_map21); + 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, 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, 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; + 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_vector(data, &c_data); + c_xmin=REAL(xmin)[0]; + c_force_continuous=LOGICAL(force_continuous)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_power_law_fit(&c_data, &c_res, c_xmin, c_force_continuous)); + /* Convert output */ + PROTECT(res=R_igraph_plfit_result_to_SEXP(&c_res)); + r_result = res; - SEXP count; + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_sir / +/-------------------------------------------*/ +SEXP R_igraph_sir(SEXP graph, SEXP beta, SEXP gamma, SEXP no_sim) { + /* 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; 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_copy(vertex_color1, &c_vertex_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); - if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); + R_SEXP_to_igraph(graph, &c_graph); + c_beta=REAL(beta)[0]; + c_gamma=REAL(gamma)[0]; + c_no_sim=(igraph_integer_t) REAL(no_sim)[0]; + if (0 != igraph_vector_ptr_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); - if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); + IGRAPH_FINALLY(R_igraph_sirlist_destroy, &c_res); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_sir(&c_graph, c_beta, c_gamma, c_no_sim, &c_res)); + + /* Convert output */ + PROTECT(res=R_igraph_sirlist_to_SEXP(&c_res)); + R_igraph_sirlist_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_convex_hull / +/-------------------------------------------*/ +SEXP R_igraph_convex_hull(SEXP data) { + /* Declarations */ + 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_matrix(data, &c_data); + if (0 != igraph_vector_int_init(&c_resverts, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); - if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 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_int_destroy, &c_edge_color2); - c_count=0; + IGRAPH_FINALLY(igraph_matrix_destroy, &c_rescoords); /* 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_convex_hull(&c_data, &c_resverts, &c_rescoords)); /* Convert output */ - igraph_vector_int_destroy(&c_vertex_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_vertex_color2); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color1); + 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); - igraph_vector_int_destroy(&c_edge_color2); + PROTECT(rescoords=R_igraph_matrix_to_SEXP(&c_rescoords)); + igraph_matrix_destroy(&c_rescoords); IGRAPH_FINALLY_CLEAN(1); - PROTECT(count=NEW_INTEGER(1)); - INTEGER(count)[0]=c_count; - r_result = count; + 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); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_dim_select / +/-------------------------------------------*/ +SEXP R_igraph_dim_select(SEXP sv) { + /* Declarations */ + igraph_vector_t c_sv; + igraph_integer_t c_dim; + SEXP dim; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_vector(sv, &c_sv); + c_dim=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_dim_select(&c_sv, &c_dim)); + + /* Convert output */ + PROTECT(dim=NEW_NUMERIC(1)); + REAL(dim)[0]=(double) c_dim; + r_result = dim; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_almost_equals / +/-------------------------------------------*/ +SEXP R_igraph_almost_equals(SEXP a, SEXP b, SEXP eps) { + /* Declarations */ + 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; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_isomorphisms_vf2 / +/ igraph_cmp_epsilon / /-------------------------------------------*/ -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_cmp_epsilon(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; - - - - SEXP maps; - + 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_copy(vertex_color1, &c_vertex_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); - if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); - if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); - if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &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_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)); + c_result=igraph_cmp_epsilon(c_a, c_b, c_eps); /* Convert output */ - igraph_vector_int_destroy(&c_vertex_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_vertex_color2); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color2); - IGRAPH_FINALLY_CLEAN(1); - 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_subisomorphic_vf2 / +/ igraph_eigen_matrix / /-------------------------------------------*/ -SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +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_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_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; - SEXP iso; - SEXP map12; - SEXP map21; + 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); - if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); - if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); - if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); - if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); - if (0 != igraph_vector_init(&c_map12, 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_complex_init(&c_values, 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_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_vector_destroy, &c_map21); - map21=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_matrix_complex_destroy, &c_vectors); + vectors=R_GlobalEnv; /* hack to have a non-NULL value */ /* 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_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(r_result=NEW_LIST(3)); PROTECT(r_names=NEW_CHARACTER(3)); - igraph_vector_int_destroy(&c_vertex_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_vertex_color2); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color2); - IGRAPH_FINALLY_CLEAN(1); - 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(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(map21=R_igraph_0orvector_to_SEXPp1(&c_map21)); - igraph_vector_destroy(&c_map21); + 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, 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, 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); @@ -6409,211 +10933,170 @@ SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SE } /*-------------------------------------------/ -/ igraph_count_subisomorphisms_vf2 / +/ igraph_eigen_matrix_symmetric / /-------------------------------------------*/ -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_eigen_matrix_symmetric(SEXP A, SEXP sA, SEXP n, SEXP algorithm, SEXP which, SEXP options) { /* 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; + 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; - SEXP count; + igraph_vector_t c_values; + igraph_matrix_t c_vectors; + SEXP values; + SEXP vectors; - SEXP r_result; + 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_copy(vertex_color1, &c_vertex_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); - if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); - if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 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_int_destroy, &c_edge_color1); - if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); + 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_int_destroy, &c_edge_color2); - c_count=0; + IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); /* 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_eigen_matrix_symmetric(&c_A, &c_sA, 0, c_n, 0, c_algorithm, &c_which, &c_options, 0, &c_values, &c_vectors)); /* Convert output */ - igraph_vector_int_destroy(&c_vertex_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_vertex_color2); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color1); + 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); - igraph_vector_int_destroy(&c_edge_color2); + PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); + igraph_matrix_destroy(&c_vectors); IGRAPH_FINALLY_CLEAN(1); - PROTECT(count=NEW_INTEGER(1)); - INTEGER(count)[0]=c_count; - r_result = count; + 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_get_subisomorphisms_vf2 / +/ igraph_solve_lsap / /-------------------------------------------*/ -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_solve_lsap(SEXP c, SEXP n) { /* 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_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(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); - if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); - if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); - if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); - if (0 != igraph_vector_ptr_init(&c_maps, 0)) { + R_SEXP_to_matrix(c, &c_c); + c_n=(igraph_integer_t) REAL(n)[0]; + if (0 != igraph_vector_int_init(&c_p, 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)); - - /* Convert output */ - igraph_vector_int_destroy(&c_vertex_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_vertex_color2); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color1); - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_edge_color2); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(maps=R_igraph_vectorlist_to_SEXP(&c_maps)); - R_igraph_vectorlist_destroy(&c_maps); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_p); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_solve_lsap(&c_c, c_n, &c_p)); + + /* Convert output */ + PROTECT(p=R_igraph_vector_int_to_SEXP(&c_p)); + igraph_vector_int_destroy(&c_p); IGRAPH_FINALLY_CLEAN(1); - r_result = maps; + r_result = p; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isomorphic_34 / +/ igraph_is_eulerian / /-------------------------------------------*/ -SEXP R_igraph_isomorphic_34(SEXP graph1, SEXP graph2) { +SEXP R_igraph_is_eulerian(SEXP graph) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_bool_t c_iso; - SEXP iso; + 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; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); + R_SEXP_to_igraph(graph, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic_34(&c_graph1, &c_graph2, &c_iso)); + IGRAPH_R_CHECK(igraph_is_eulerian(&c_graph, &c_has_path, &c_has_cycle)); /* Convert output */ - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - r_result = iso; + 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(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_canonical_permutation / +/ igraph_eulerian_path / /-------------------------------------------*/ -SEXP R_igraph_canonical_permutation(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_vector_t c_labeling; - igraph_bliss_sh_t c_sh; - igraph_bliss_info_t c_info; - SEXP labeling; - 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_copy(colors, &c_colors); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + if (0 != igraph_vector_int_init(&c_edge_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - if (0 != igraph_vector_init(&c_labeling, 0)) { + 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_destroy, &c_labeling); - c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_res); /* 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_eulerian_path(&c_graph, &c_edge_res, &c_vertex_res)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - igraph_vector_int_destroy(&c_colors); + PROTECT(edge_res=R_igraph_vector_int_to_SEXPp1(&c_edge_res)); + igraph_vector_int_destroy(&c_edge_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(labeling=R_igraph_vector_to_SEXPp1(&c_labeling)); - igraph_vector_destroy(&c_labeling); + PROTECT(vertex_res=R_igraph_vector_int_to_SEXPp1(&c_vertex_res)); + igraph_vector_int_destroy(&c_vertex_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, 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_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); @@ -6622,199 +11105,197 @@ SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { } /*-------------------------------------------/ -/ igraph_permute_vertices / +/ igraph_eulerian_cycle / /-------------------------------------------*/ -SEXP R_igraph_permute_vertices(SEXP graph, SEXP permutation) { +SEXP R_igraph_eulerian_cycle(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_t c_res; - igraph_vector_t c_permutation; - SEXP res; + 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); - R_SEXP_to_vector(permutation, &c_permutation); + 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_permute_vertices(&c_graph, &c_res, &c_permutation)); + IGRAPH_R_CHECK(igraph_eulerian_cycle(&c_graph, &c_edge_res, &c_vertex_res)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_res); - PROTECT(res=R_igraph_to_SEXP(&c_res)); - IGRAPH_I_DESTROY(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(edge_res=R_igraph_vector_int_to_SEXPp1(&c_edge_res)); + igraph_vector_int_destroy(&c_edge_res); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(vertex_res=R_igraph_vector_int_to_SEXPp1(&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_isomorphic_bliss / +/ igraph_fundamental_cycles / /-------------------------------------------*/ -SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colors2, SEXP sh) { +SEXP R_igraph_fundamental_cycles(SEXP graph, SEXP start, SEXP bfs_cutoff, SEXP weights) { /* 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_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(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(colors1)) { - R_SEXP_to_vector_int_copy(colors1, &c_colors1); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors1, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors1); - if (!Rf_isNull(colors2)) { - R_SEXP_to_vector_int_copy(colors2, &c_colors2); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors2, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors2); - if (0 != igraph_vector_init(&c_map12, 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_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_int_list_destroy, &c_basis); + if (!Rf_isNull(start)) { + c_start = (igraph_integer_t) REAL(start)[0]; } - 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); + c_bfs_cutoff=(igraph_integer_t) REAL(bfs_cutoff)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* 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_fundamental_cycles(&c_graph, &c_basis, (Rf_isNull(start) ? 0 : c_start), c_bfs_cutoff, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(r_result=NEW_LIST(5)); - PROTECT(r_names=NEW_CHARACTER(5)); - igraph_vector_int_destroy(&c_colors1); + PROTECT(basis=R_igraph_vector_int_list_to_SEXPp1(&c_basis)); + igraph_vector_int_list_destroy(&c_basis); IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_colors2); - IGRAPH_FINALLY_CLEAN(1); - 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")); - SET_NAMES(r_result, r_names); - UNPROTECT(6); + r_result = basis; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_automorphisms / +/ igraph_minimum_cycle_basis / /-------------------------------------------*/ -SEXP R_igraph_automorphisms(SEXP graph, SEXP colors, SEXP sh) { +SEXP R_igraph_minimum_cycle_basis(SEXP graph, SEXP bfs_cutoff, SEXP complete, SEXP use_cycle_order, SEXP weights) { /* 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_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_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { - R_SEXP_to_vector_int_copy(colors, &c_colors); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); + if (0 != igraph_vector_int_list_init(&c_basis, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_basis); + c_bfs_cutoff=(igraph_integer_t) REAL(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_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), c_sh, &c_info)); + 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 */ - igraph_vector_int_destroy(&c_colors); + PROTECT(basis=R_igraph_vector_int_list_to_SEXPp1(&c_basis)); + igraph_vector_int_list_destroy(&c_basis); IGRAPH_FINALLY_CLEAN(1); - PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); - if (c_info.group_size) { free(c_info.group_size); } - r_result = info; + r_result = basis; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_automorphism_group / +/ igraph_is_tree / /-------------------------------------------*/ -SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { +SEXP R_igraph_is_tree(SEXP graph, SEXP mode) { /* 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_bool_t c_res; + igraph_integer_t c_root; + igraph_neimode_t c_mode; + SEXP res; + SEXP root; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { - R_SEXP_to_vector_int_copy(colors, &c_colors); - } else { - IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - if (0 != igraph_vector_ptr_init(&c_generators, 0)) { + c_root = -1; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_tree(&c_graph, &c_res, &c_root, c_mode)); + + /* 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_is_forest / +/-------------------------------------------*/ +SEXP R_igraph_is_forest(SEXP graph, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_bool_t c_res; + igraph_vector_int_t c_roots; + igraph_neimode_t c_mode; + SEXP res; + SEXP roots; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_roots, 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_roots); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* 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_is_forest(&c_graph, &c_res, &c_roots, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - igraph_vector_int_destroy(&c_colors); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(generators=R_igraph_vectorlist_to_SEXP_p1(&c_generators)); - R_igraph_vectorlist_destroy(&c_generators); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + PROTECT(roots=R_igraph_vector_int_to_SEXPp1(&c_roots)); + igraph_vector_int_destroy(&c_roots); 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_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); @@ -6823,159 +11304,121 @@ SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { } /*-------------------------------------------/ -/ igraph_simplify_and_colorize / +/ igraph_from_prufer / /-------------------------------------------*/ -SEXP R_igraph_simplify_and_colorize(SEXP graph) { +SEXP R_igraph_from_prufer(SEXP prufer) { /* 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_t c_prufer; + SEXP graph; - 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)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color); + R_SEXP_to_vector_int_copy(prufer, &c_prufer); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_prufer); /* Call igraph */ - IGRAPH_R_CHECK(igraph_simplify_and_colorize(&c_graph, &c_res, &c_vertex_color, &c_edge_color)); + IGRAPH_R_CHECK(igraph_from_prufer(&c_graph, &c_prufer)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - IGRAPH_FINALLY(igraph_destroy, &c_res); - PROTECT(res=R_igraph_to_SEXP(&c_res)); - IGRAPH_I_DESTROY(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(vertex_color=R_igraph_vector_int_to_SEXP(&c_vertex_color)); - igraph_vector_int_destroy(&c_vertex_color); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(edge_color=R_igraph_vector_int_to_SEXP(&c_edge_color)); - igraph_vector_int_destroy(&c_edge_color); + igraph_vector_int_destroy(&c_prufer); 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 = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_scg_grouping / +/ igraph_to_prufer / /-------------------------------------------*/ -SEXP R_igraph_scg_grouping(SEXP V, SEXP nt, SEXP nt_vec, SEXP mtype, SEXP algo, SEXP p, SEXP maxiter) { +SEXP R_igraph_to_prufer(SEXP graph) { /* 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_t c_prufer; + SEXP prufer; 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_init(&c_prufer, 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_destroy, &c_prufer); /* 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_to_prufer(&c_graph, &c_prufer)); /* Convert output */ - PROTECT(groups=R_igraph_vector_to_SEXPp1(&c_groups)); - igraph_vector_destroy(&c_groups); + PROTECT(prufer=R_igraph_vector_int_to_SEXPp1(&c_prufer)); + igraph_vector_int_destroy(&c_prufer); IGRAPH_FINALLY_CLEAN(1); - r_result = groups; + r_result = prufer; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_scg_norm_eps / +/ igraph_tree_from_parent_vector / /-------------------------------------------*/ -SEXP R_igraph_scg_norm_eps(SEXP V, SEXP groups, SEXP mtype, SEXP p, SEXP norm) { +SEXP R_igraph_tree_from_parent_vector(SEXP parents, SEXP type) { /* 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_vector_int_t c_parents; + igraph_tree_mode_t c_type; + SEXP graph; SEXP r_result; /* 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_vector_int_copy(parents, &c_parents); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); + c_type = (igraph_tree_mode_t) Rf_asInteger(type); /* 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_tree_from_parent_vector(&c_graph, &c_parents, c_type)); /* Convert output */ - PROTECT(eps=R_igraph_vector_to_SEXP(&c_eps)); - igraph_vector_destroy(&c_eps); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = eps; + igraph_vector_int_destroy(&c_parents); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_matching / +/ igraph_random_spanning_tree / /-------------------------------------------*/ -SEXP R_igraph_is_matching(SEXP graph, SEXP types, SEXP matching) { +SEXP R_igraph_random_spanning_tree(SEXP graph, SEXP vid) { /* 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_res; + igraph_integer_t c_vid; 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_long_copy(matching, &c_matching); + if (0 != igraph_vector_int_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + if (!Rf_isNull(vid)) { + c_vid = (igraph_integer_t) REAL(vid)[0]; + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); + IGRAPH_R_CHECK(igraph_random_spanning_tree(&c_graph, &c_res, (Rf_isNull(vid) ? 0 : c_vid))); /* Convert output */ - igraph_vector_long_destroy(&c_matching); - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; + PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); + igraph_vector_int_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -6983,484 +11426,341 @@ SEXP R_igraph_is_matching(SEXP graph, SEXP types, SEXP matching) { } /*-------------------------------------------/ -/ igraph_is_maximal_matching / +/ igraph_tree_game / /-------------------------------------------*/ -SEXP R_igraph_is_maximal_matching(SEXP graph, SEXP types, SEXP matching) { +SEXP R_igraph_tree_game(SEXP n, SEXP directed, SEXP method) { /* 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_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_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); + c_n=(igraph_integer_t) REAL(n)[0]; + c_directed=LOGICAL(directed)[0]; + c_method = (igraph_random_tree_t) Rf_asInteger(method); /* 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_tree_game(&c_graph, c_n, c_directed, c_method)); /* 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_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_maximum_bipartite_matching / +/ igraph_vertex_coloring_greedy / /-------------------------------------------*/ -SEXP R_igraph_maximum_bipartite_matching(SEXP graph, SEXP types, SEXP weights, SEXP eps) { +SEXP R_igraph_vertex_coloring_greedy(SEXP graph, SEXP heuristic) { /* 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_colors; + igraph_coloring_greedy_t c_heuristic; + SEXP colors; - 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_colors, 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_colors); + c_heuristic = (igraph_coloring_greedy_t) Rf_asInteger(heuristic); /* 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_vertex_coloring_greedy(&c_graph, &c_colors, c_heuristic)); /* 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(colors=R_igraph_vector_int_to_SEXP(&c_colors)); + igraph_vector_int_destroy(&c_colors); 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 = colors; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eigen_adjacency / +/ igraph_deterministic_optimal_imitation / /-------------------------------------------*/ -SEXP R_igraph_eigen_adjacency(SEXP graph, SEXP algorithm, SEXP which, SEXP options) { +SEXP R_igraph_deterministic_optimal_imitation(SEXP graph, SEXP vid, SEXP optimality, SEXP quantities, SEXP strategies, SEXP mode) { /* 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; + 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_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)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_complex_destroy, &c_cmplxvectors); - cmplxvectors=R_GlobalEnv; /* hack to have a non-NULL value */ + 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_copy(strategies, &c_strategies); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* 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_deterministic_optimal_imitation(&c_graph, c_vid, c_optimality, &c_quantities, &c_strategies, c_mode)); /* 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); + PROTECT(strategies=R_igraph_vector_int_to_SEXP(&c_strategies)); + igraph_vector_int_destroy(&c_strategies); 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(6); + r_result = strategies; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_power_law_fit / +/ igraph_moran_process / /-------------------------------------------*/ -SEXP R_igraph_power_law_fit(SEXP data, SEXP xmin, SEXP force_continuous) { +SEXP R_igraph_moran_process(SEXP graph, SEXP weights, SEXP quantities, SEXP strategies, SEXP mode) { /* 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_vector_t c_weights; + igraph_vector_t c_quantities; + igraph_vector_int_t c_strategies; + igraph_neimode_t c_mode; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_vector(data, &c_data); - c_xmin=REAL(xmin)[0]; - c_force_continuous=LOGICAL(force_continuous)[0]; + 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_copy(strategies, &c_strategies); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_power_law_fit(&c_data, &c_res, c_xmin, c_force_continuous)); + IGRAPH_R_CHECK(igraph_moran_process(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_quantities, &c_strategies, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_plfit_result_to_SEXP(&c_res)); - r_result = res; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + 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); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_sir / +/ igraph_roulette_wheel_imitation / /-------------------------------------------*/ -SEXP R_igraph_sir(SEXP graph, SEXP beta, SEXP gamma, SEXP no_sim) { +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_real_t c_beta; - igraph_real_t c_gamma; - igraph_integer_t c_no_sim; - igraph_vector_ptr_t c_res; - SEXP 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; /* 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)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_sirlist_destroy, &c_res); + R_SEXP_to_igraph(graph, &c_graph); + 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_copy(strategies, &c_strategies); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_sir(&c_graph, c_beta, c_gamma, c_no_sim, &c_res)); + IGRAPH_R_CHECK(igraph_roulette_wheel_imitation(&c_graph, c_vid, c_is_local, &c_quantities, &c_strategies, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_sirlist_to_SEXP(&c_res)); - R_igraph_sirlist_destroy(&c_res); + PROTECT(strategies=R_igraph_vector_int_to_SEXP(&c_strategies)); + igraph_vector_int_destroy(&c_strategies); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = strategies; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_convex_hull / +/ igraph_stochastic_imitation / /-------------------------------------------*/ -SEXP R_igraph_convex_hull(SEXP data) { +SEXP R_igraph_stochastic_imitation(SEXP graph, SEXP vid, SEXP algo, 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_imitate_algorithm_t c_algo; + 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_algo = (igraph_imitate_algorithm_t) Rf_asInteger(algo); + R_SEXP_to_vector(quantities, &c_quantities); + R_SEXP_to_vector_int_copy(strategies, &c_strategies); + IGRAPH_FINALLY(igraph_vector_int_destroy, &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_stochastic_imitation(&c_graph, c_vid, c_algo, &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_has_attribute_table / /-------------------------------------------*/ -SEXP R_igraph_dim_select(SEXP sv) { +SEXP R_igraph_has_attribute_table() { /* Declarations */ - igraph_vector_t c_sv; - igraph_integer_t c_dim; - SEXP dim; - + igraph_bool_t c_result; SEXP r_result; /* Convert input */ - R_SEXP_to_vector(sv, &c_sv); - c_dim=0; + /* Call igraph */ - IGRAPH_R_CHECK(igraph_dim_select(&c_sv, &c_dim)); + c_result=igraph_has_attribute_table(); /* Convert output */ - PROTECT(dim=NEW_INTEGER(1)); - INTEGER(dim)[0]=c_dim; - r_result = dim; + + PROTECT(r_result=NEW_LOGICAL(1)); + LOGICAL(r_result)[0]=c_result; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_eulerian / +/ igraph_progress / /-------------------------------------------*/ -SEXP R_igraph_is_eulerian(SEXP graph) { +SEXP R_igraph_progress(SEXP message, SEXP percent) { /* Declarations */ - igraph_t c_graph; - igraph_bool_t c_has_path; - igraph_bool_t c_has_cycle; - SEXP has_path; - SEXP has_cycle; + 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_percent=REAL(percent)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_eulerian(&c_graph, &c_has_path, &c_has_cycle)); + 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(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(3); + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eulerian_path / +/ igraph_status / /-------------------------------------------*/ -SEXP R_igraph_eulerian_path(SEXP graph) { +SEXP R_igraph_status(SEXP message) { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_edge_res; - igraph_vector_t c_vertex_res; - SEXP edge_res; - SEXP vertex_res; + const char* c_message; - SEXP r_result, r_names; + int 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_path(&c_graph, &c_edge_res, &c_vertex_res)); + IGRAPH_R_CHECK(igraph_status(c_message, 0)); /* 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); + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eulerian_cycle / +/ igraph_strerror / /-------------------------------------------*/ -SEXP R_igraph_eulerian_cycle(SEXP graph) { +SEXP R_igraph_strerror(SEXP igraph_errno) { /* 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; + int c_igraph_errno; + const char* 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_strerror(c_igraph_errno); /* 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); + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_tree / +/ igraph_expand_path_to_pairs / /-------------------------------------------*/ -SEXP R_igraph_is_tree(SEXP graph, SEXP mode) { +SEXP R_igraph_expand_path_to_pairs(SEXP path) { /* Declarations */ - igraph_t c_graph; - igraph_bool_t c_res; - igraph_integer_t c_root; - igraph_neimode_t c_mode; - SEXP res; - SEXP root; + igraph_vector_int_t c_path; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - c_root = -1; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_vector_int_copy(path, &c_path); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_tree(&c_graph, &c_res, &c_root, c_mode)); + IGRAPH_R_CHECK(igraph_expand_path_to_pairs(&c_path)); /* 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); + PROTECT(path=R_igraph_vector_int_to_SEXPp1(&c_path)); + igraph_vector_int_destroy(&c_path); + IGRAPH_FINALLY_CLEAN(1); + r_result = path; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_from_prufer / +/ igraph_invalidate_cache / /-------------------------------------------*/ -SEXP R_igraph_from_prufer(SEXP prufer) { +SEXP R_igraph_invalidate_cache(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_prufer; - SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(prufer, &c_prufer); - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_prufer); + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_from_prufer(&c_graph, &c_prufer)); + igraph_invalidate_cache(&c_graph); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&c_prufer); - IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -7468,121 +11768,126 @@ SEXP R_igraph_from_prufer(SEXP prufer) { } /*-------------------------------------------/ -/ igraph_to_prufer / +/ igraph_vertex_path_from_edge_path / /-------------------------------------------*/ -SEXP R_igraph_to_prufer(SEXP graph) { +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_prufer; - SEXP prufer; + 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_prufer, 0)) { + c_start = (igraph_integer_t) REAL(start)[0]; + R_SEXP_to_vector_int_copy(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_prufer); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_path); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_prufer(&c_graph, &c_prufer)); + IGRAPH_R_CHECK(igraph_vertex_path_from_edge_path(&c_graph, c_start, &c_edge_path, &c_vertex_path, c_mode)); /* Convert output */ - PROTECT(prufer=R_igraph_vector_int_to_SEXP(&c_prufer)); - igraph_vector_int_destroy(&c_prufer); + PROTECT(vertex_path=R_igraph_vector_int_to_SEXPp1(&c_vertex_path)); + igraph_vector_int_destroy(&c_vertex_path); IGRAPH_FINALLY_CLEAN(1); - r_result = prufer; + r_result = vertex_path; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_random_spanning_tree / +/ igraph_version / /-------------------------------------------*/ -SEXP R_igraph_random_spanning_tree(SEXP graph, SEXP vid) { +SEXP R_igraph_version() { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_res; - igraph_integer_t c_vid; - SEXP res; + 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; + 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_vid = (igraph_integer_t) REAL(vid)[0]; + /* Call igraph */ - IGRAPH_R_CHECK(igraph_random_spanning_tree(&c_graph, &c_res, c_vid)); + igraph_version(&c_version_string, &c_major, &c_minor, &c_subminor); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXPp1(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - r_result = res; + 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); } /*-------------------------------------------/ -/ igraph_tree_game / +/ igraph_get_stochastic_sparsemat / /-------------------------------------------*/ -SEXP R_igraph_tree_game(SEXP n, SEXP directed, SEXP method) { +SEXP R_igraph_get_stochastic_sparsemat(SEXP graph, SEXP column_wise) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_bool_t c_directed; - igraph_random_tree_t c_method; - SEXP graph; + igraph_sparsemat_t c_sparsemat; + igraph_bool_t c_column_wise; + SEXP sparsemat; 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(graph, &c_graph); + /* Don't need to init. */ + c_column_wise=LOGICAL(column_wise)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_tree_game(&c_graph, c_n, c_directed, c_method)); + IGRAPH_R_CHECK(igraph_get_stochastic_sparsemat(&c_graph, &c_sparsemat, c_column_wise)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); + igraph_sparsemat_destroy(&c_sparsemat); + r_result = sparsemat; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_vertex_coloring_greedy / +/ igraph_hrg_dendrogram / /-------------------------------------------*/ -SEXP R_igraph_vertex_coloring_greedy(SEXP graph, SEXP heuristic) { +SEXP R_igraph_hrg_dendrogram(SEXP hrg) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_colors; - igraph_coloring_greedy_t c_heuristic; - SEXP colors; + igraph_hrg_t c_hrg; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_colors, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - c_heuristic = (igraph_coloring_greedy_t) Rf_asInteger(heuristic); + R_SEXP_to_hrg(hrg, &c_hrg); /* Call igraph */ - IGRAPH_R_CHECK(igraph_vertex_coloring_greedy(&c_graph, &c_colors, c_heuristic)); + IGRAPH_R_CHECK(igraph_hrg_dendrogram(&c_graph, &c_hrg)); /* Convert output */ - PROTECT(colors=R_igraph_vector_int_to_SEXP(&c_colors)); - igraph_vector_int_destroy(&c_colors); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = colors; + r_result = graph; UNPROTECT(1); return(r_result); diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 0226fab55f0..6ae150f6a89 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -22,8 +22,9 @@ */ #include "igraph.h" -#include "graph/attributes.h" -#include "graph/neighbors.h" +#include "igraph_neighborhood.h" +#include "vendor/cigraph/src/graph/internal.h" +#include "vendor/cigraph/src/graph/attributes.h" #include "config.h" @@ -59,26 +60,21 @@ 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_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_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); @@ -96,19 +92,15 @@ 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); 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_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it, igraph_vector_int_t *data); +int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it, igraph_vector_int_t *data); 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_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_copy(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); @@ -118,8 +110,7 @@ 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_vector_int_list_to_SEXPp1(const igraph_vector_int_list_t *list); 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_to_SEXPp1(const igraph_vector_t *v); @@ -169,9 +160,8 @@ SEXP R_igraph_i_lang7(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w, SEXP x, SEXP y) SEXP R_igraph_getListElement(SEXP list, const char *str) { SEXP elmt = R_NilValue, names = Rf_getAttrib(list, R_NamesSymbol); - int i; - for (i = 0; i < Rf_length(list); i++) + for (R_xlen_t i = 0; i < Rf_xlength(list); i++) if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { elmt = VECTOR_ELT(list, i); break; @@ -285,11 +275,11 @@ SEXP R_igraph_handle_safe_eval_result(SEXP result) { SEXP R_igraph_get_attr_mode(SEXP graph, SEXP pwhich) { int which=INTEGER(pwhich)[0]-1; SEXP obj=VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), which); - int i, len=GET_LENGTH(obj); + igraph_integer_t len=Rf_xlength(obj); SEXP result; PROTECT(result=NEW_CHARACTER(len)); - for (i=0; iattr=result; /* Add graph attributes */ - attrno= attr==NULL ? 0 : igraph_vector_ptr_size(attr); + igraph_integer_t attrno= attr==NULL ? 0 : igraph_vector_ptr_size(attr); SET_VECTOR_ELT(result, 1, NEW_LIST(attrno)); gal=VECTOR_ELT(result, 1); PROTECT(names=NEW_CHARACTER(attrno)); px++; - for (i=0; iattr; if (ga && va && ea) { @@ -485,7 +472,7 @@ SEXP R_igraph_attribute_add_vertices_append1(igraph_vector_ptr_t *nattr, SEXP app = R_NilValue; igraph_attribute_record_t *tmprec=VECTOR(*nattr)[j-1]; - long int len = 0; + igraph_integer_t len = 0; switch (tmprec->type) { case IGRAPH_ATTRIBUTE_NUMERIC: @@ -497,7 +484,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; @@ -532,14 +519,14 @@ SEXP R_igraph_attribute_add_vertices_append1(igraph_vector_ptr_t *nattr, return app; } -void R_igraph_attribute_add_vertices_append(SEXP val, long int nv, +void R_igraph_attribute_add_vertices_append(SEXP val, igraph_integer_t nv, igraph_vector_ptr_t *nattr) { SEXP names; - long int valno, i, nattrno; + igraph_integer_t valno, nattrno; SEXP rep = R_NilValue; int px = 0; - valno=GET_LENGTH(val); + valno = Rf_xlength(val); names=PROTECT(GET_NAMES(val)); px++; if (nattr==NULL) { nattrno=0; @@ -547,11 +534,11 @@ void R_igraph_attribute_add_vertices_append(SEXP val, long int nv, nattrno=igraph_vector_ptr_size(nattr); } - for (i=0; iname); @@ -567,7 +554,7 @@ void R_igraph_attribute_add_vertices_append(SEXP val, long int nv, if (Rf_isNull(rep)) { SEXP l1 = PROTECT(Rf_install("rep")); px++; SEXP l2 = PROTECT(Rf_ScalarLogical(NA_LOGICAL)); px++; - SEXP l3 = PROTECT(Rf_ScalarInteger((int) nv)); px++; + SEXP l3 = PROTECT(Rf_ScalarReal((double) nv)); px++; SEXP l4 = PROTECT(Rf_lang3(l1, l2, l3)); px++; PROTECT(rep=Rf_eval(l4, R_GlobalEnv)); px++; } @@ -586,19 +573,19 @@ 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; - igraph_vector_t news; - long int valno, i, origlen, nattrno, newattrs; + igraph_vector_int_t news; + igraph_integer_t valno, origlen, nattrno, newattrs; int px = 0; SEXP newattr = PROTECT(R_igraph_attribute_add_vertices_dup(attr)); px++; attr=graph->attr=newattr; val=VECTOR_ELT(attr, 2); - valno=GET_LENGTH(val); + valno=Rf_xlength(val); names=PROTECT(GET_NAMES(val)); px++; if (nattr==NULL) { nattrno=0; @@ -609,19 +596,18 @@ int R_igraph_attribute_add_vertices(igraph_t *graph, long int nv, /* First add the new attributes, if any */ newattrs=0; - if (igraph_vector_init(&news, 0)) Rf_error("Out of memory"); - IGRAPH_FINALLY(igraph_vector_destroy, &news); - for (i=0; iname; - long int j; igraph_bool_t l=0; - for (j=0; !l && jname)); } @@ -646,7 +631,7 @@ int R_igraph_attribute_add_vertices(igraph_t *graph, long int nv, val=VECTOR_ELT(attr, 2); UNPROTECT(9); } - igraph_vector_destroy(&news); + igraph_vector_int_destroy(&news); IGRAPH_FINALLY_CLEAN(1); /* news */ /* Now append the new values */ @@ -717,11 +702,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); + igraph_integer_t valno; + igraph_integer_t idxlen = igraph_vector_int_size(idx); SEXP ss; int px = 0; @@ -730,18 +715,18 @@ int R_igraph_attribute_permute_vertices_same(const igraph_t *graph, attr=newgraph->attr=newattr; val=VECTOR_ELT(attr,2); - valno=GET_LENGTH(val); + valno=Rf_xlength(val); /* If we have no vertex attributes, then we don't need to do anything */ if (valno==0) { UNPROTECT(px); return 0; } /* 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); + igraph_integer_t valno; + igraph_integer_t idxlen=igraph_vector_int_size(idx); SEXP ss; int px = 0; val=VECTOR_ELT(attr,2); - valno=GET_LENGTH(val); + valno=Rf_xlength(val); /* If we have no vertex attributes, then we don't need to do anything */ if (valno==0) { return 0; } /* Convert idx to an R object, we will use this for indexing */ - PROTECT(ss=NEW_INTEGER(idxlen)); px++; - for (i=0; itype) { case IGRAPH_ATTRIBUTE_NUMERIC: @@ -834,7 +819,7 @@ SEXP R_igraph_attribute_add_edges_append1(igraph_vector_ptr_t *nattr, int j, 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; @@ -870,15 +855,15 @@ 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; + igraph_integer_t ealno; + igraph_integer_t ne=igraph_vector_int_size(edges)/2, nattrno; SEXP rep = R_NilValue; int px = 0; - ealno=GET_LENGTH(eal); + ealno=Rf_xlength(eal); names=PROTECT(GET_NAMES(eal)); px++; if (nattr==NULL) { nattrno=0; @@ -886,11 +871,11 @@ void R_igraph_attribute_add_edges_append(SEXP eal, nattrno=igraph_vector_ptr_size(nattr); } - for (i=0; iname); @@ -906,7 +891,7 @@ void R_igraph_attribute_add_edges_append(SEXP eal, if (Rf_isNull(rep)) { SEXP l1 = PROTECT(Rf_install("rep")); px++; SEXP l2 = PROTECT(Rf_ScalarLogical(NA_LOGICAL)); px++; - SEXP l3 = PROTECT(Rf_ScalarInteger((int) ne)); px++; + SEXP l3 = PROTECT(Rf_ScalarReal((double) ne)); px++; SEXP l4 = PROTECT(Rf_lang3(l1, l2, l3)); px++; PROTECT(rep = Rf_eval(l4, R_GlobalEnv)); px++; } @@ -919,24 +904,23 @@ 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_vector_ptr_t *nattr) { +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; + igraph_vector_int_t news; + igraph_integer_t ealno, origlen, nattrno, newattrs; + igraph_integer_t ne=igraph_vector_int_size(edges)/2; int px = 0; - if (igraph_vector_init(&news, 0)) Rf_error("Out of memory"); - IGRAPH_FINALLY(igraph_vector_destroy, &news); + if (igraph_vector_int_init(&news, 0)) Rf_error("Out of memory"); + IGRAPH_FINALLY(igraph_vector_int_destroy, &news); SEXP newattr = PROTECT(R_igraph_attribute_add_edges_dup(attr)); px++; attr=graph->attr=newattr; eal=VECTOR_ELT(attr, 3); - ealno=GET_LENGTH(eal); + ealno=Rf_xlength(eal); names=PROTECT(GET_NAMES(eal)); px++; if (nattr==NULL) { nattrno=0; @@ -947,17 +931,16 @@ int R_igraph_attribute_add_edges(igraph_t *graph, /* First add the new attributes, if any */ newattrs=0; - for (i=0; iname; - long int j; igraph_bool_t l=0; - for (j=0; !l && jname)); } @@ -982,7 +965,7 @@ int R_igraph_attribute_add_edges(igraph_t *graph, eal=VECTOR_ELT(attr, 3); UNPROTECT(9); } - igraph_vector_destroy(&news); + igraph_vector_int_destroy(&news); IGRAPH_FINALLY_CLEAN(1); /* Now append the new values */ @@ -1028,12 +1011,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); + igraph_integer_t ealno; + igraph_integer_t idxlen=igraph_vector_int_size(idx); SEXP ss; int px = 0; @@ -1042,18 +1025,18 @@ int R_igraph_attribute_permute_edges_same(const igraph_t *graph, attr=newgraph->attr=newattr; eal=VECTOR_ELT(attr,3); - ealno=GET_LENGTH(eal); + ealno = Rf_xlength(eal); /* If we have no edge attributes, then we don't need to do anything */ if (ealno==0) { UNPROTECT(px); return 0; } /* 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); + igraph_integer_t ealno; + igraph_integer_t idxlen=igraph_vector_int_size(idx); SEXP ss; eal=VECTOR_ELT(attr,3); - ealno=GET_LENGTH(eal); + ealno = Rf_xlength(eal); /* If we have no vertex attributes, then we don't need to do anything */ if (ealno==0) { return 0; } /* 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++) { + for (igraph_integer_t 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 */ @@ -1149,17 +1130,17 @@ int R_igraph_attribute_get_info(const igraph_t *graph, } if (t) { /* return types */ - igraph_vector_resize(t, GET_LENGTH(al)); - for (j=0; jattr, 1); @@ -1251,7 +1232,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); @@ -1270,7 +1251,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 */ @@ -1290,7 +1271,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) { @@ -1312,20 +1293,20 @@ int R_igraph_attribute_get_numeric_vertex_attr(const igraph_t *graph, *value=newvalue; } else { igraph_vit_t it; - long int i=0; + igraph_integer_t i=0; IGRAPH_CHECK(igraph_vit_create(graph, vs, &it)); IGRAPH_FINALLY(igraph_vit_destroy, &it); IGRAPH_CHECK(igraph_vector_resize(value, IGRAPH_VIT_SIZE(it))); if (IS_NUMERIC(va)) { while (!IGRAPH_VIT_END(it)) { - long int v=IGRAPH_VIT_GET(it); + igraph_integer_t v=IGRAPH_VIT_GET(it); VECTOR(*value)[i]=REAL(va)[v]; IGRAPH_VIT_NEXT(it); i++; } } else if (IS_INTEGER(va)) { while (!IGRAPH_VIT_END(it)) { - long int v=IGRAPH_VIT_GET(it); + igraph_integer_t v=IGRAPH_VIT_GET(it); VECTOR(*value)[i]=INTEGER(va)[v]; IGRAPH_VIT_NEXT(it); i++; @@ -1338,7 +1319,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) { @@ -1360,12 +1341,12 @@ int R_igraph_attribute_get_bool_vertex_attr(const igraph_t *graph, *value=newvalue; } else { igraph_vit_t it; - long int i=0; + igraph_integer_t i=0; IGRAPH_CHECK(igraph_vit_create(graph, vs, &it)); IGRAPH_FINALLY(igraph_vit_destroy, &it); IGRAPH_CHECK(igraph_vector_bool_resize(value, IGRAPH_VIT_SIZE(it))); while (!IGRAPH_VIT_END(it)) { - long int v=IGRAPH_VIT_GET(it); + igraph_integer_t v=IGRAPH_VIT_GET(it); VECTOR(*value)[i]=LOGICAL(va)[v]; IGRAPH_VIT_NEXT(it); i++; @@ -1377,7 +1358,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) { @@ -1397,12 +1378,12 @@ int R_igraph_attribute_get_string_vertex_attr(const igraph_t *graph, R_igraph_SEXP_to_strvector_copy(va, value); } else { igraph_vit_t it; - long int i=0; + igraph_integer_t i=0; IGRAPH_CHECK(igraph_vit_create(graph, vs, &it)); IGRAPH_FINALLY(igraph_vit_destroy, &it); IGRAPH_CHECK(igraph_strvector_resize(value, IGRAPH_VIT_SIZE(it))); while (!IGRAPH_VIT_END(it)) { - long int v=IGRAPH_VIT_GET(it); + igraph_integer_t v=IGRAPH_VIT_GET(it); const char *str=CHAR(STRING_ELT(va, v)); IGRAPH_CHECK(igraph_strvector_set(value, i, str)); IGRAPH_VIT_NEXT(it); @@ -1415,7 +1396,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) { @@ -1437,20 +1418,20 @@ int R_igraph_attribute_get_numeric_edge_attr(const igraph_t *graph, *value=newvalue; } else { igraph_eit_t it; - long int i=0; + igraph_integer_t i=0; IGRAPH_CHECK(igraph_eit_create(graph, es, &it)); IGRAPH_FINALLY(igraph_eit_destroy, &it); IGRAPH_CHECK(igraph_vector_resize(value, IGRAPH_EIT_SIZE(it))); if (IS_NUMERIC(ea)) { while (!IGRAPH_EIT_END(it)) { - long int e=IGRAPH_EIT_GET(it); + igraph_integer_t e=IGRAPH_EIT_GET(it); VECTOR(*value)[i]=REAL(ea)[e]; IGRAPH_EIT_NEXT(it); i++; } } else { /* INTEGER */ while (!IGRAPH_EIT_END(it)) { - long int e=IGRAPH_EIT_GET(it); + igraph_integer_t e=IGRAPH_EIT_GET(it); VECTOR(*value)[i]=INTEGER(ea)[e]; IGRAPH_EIT_NEXT(it); i++; @@ -1463,7 +1444,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) { @@ -1485,12 +1466,12 @@ int R_igraph_attribute_get_bool_edge_attr(const igraph_t *graph, *value=newvalue; } else { igraph_eit_t it; - long int i=0; + igraph_integer_t i=0; IGRAPH_CHECK(igraph_eit_create(graph, es, &it)); IGRAPH_FINALLY(igraph_eit_destroy, &it); IGRAPH_CHECK(igraph_vector_bool_resize(value, IGRAPH_EIT_SIZE(it))); while (!IGRAPH_EIT_END(it)) { - long int e=IGRAPH_EIT_GET(it); + igraph_integer_t e=IGRAPH_EIT_GET(it); VECTOR(*value)[i]=LOGICAL(ea)[e]; IGRAPH_EIT_NEXT(it); i++; @@ -1502,7 +1483,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) { @@ -1521,12 +1502,12 @@ int R_igraph_attribute_get_string_edge_attr(const igraph_t *graph, R_igraph_SEXP_to_strvector_copy(ea, value); } else { igraph_eit_t it; - long int i=0; + igraph_integer_t i=0; IGRAPH_CHECK(igraph_eit_create(graph, es, &it)); IGRAPH_FINALLY(igraph_eit_destroy, &it); IGRAPH_CHECK(igraph_strvector_resize(value, IGRAPH_EIT_SIZE(it))); while (!IGRAPH_EIT_END(it)) { - long int e=IGRAPH_EIT_GET(it); + igraph_integer_t e=IGRAPH_EIT_GET(it); const char *str=CHAR(STRING_ELT(ea, e)); IGRAPH_CHECK(igraph_strvector_set(value, i, str)); IGRAPH_EIT_NEXT(it); @@ -1540,20 +1521,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); + igraph_integer_t 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; - for (j=1; j 0 ? REAL(attr2)[ VECTOR(*v)[0] ] : NA_REAL; + for (igraph_integer_t j=1; j 0 ? REAL(attr2)[(long) VECTOR(*v)[0] ] : NA_REAL; - for (j=1; j 0 ? REAL(attr2)[VECTOR(*v)[0] ] : NA_REAL; + for (igraph_integer_t j=1; j m) { m=val; @@ -1642,26 +1623,26 @@ 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); + igraph_integer_t len=igraph_vector_int_list_size(merges); PROTECT(attr2=AS_NUMERIC(attr)); PROTECT(res=NEW_NUMERIC(len)); RNG_BEGIN(); - for (i=0; i0 ? 0.0 : NA_REAL; - for (j=0; j0) { s=s/n; } @@ -1743,26 +1724,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); + igraph_integer_t len=igraph_vector_int_list_size(merges); PROTECT(attr2=AS_NUMERIC(attr)); PROTECT(res=NEW_NUMERIC(len)); - for (i=0; iattr; SEXP toattr=newgraph->attr; SEXP val=VECTOR_ELT(attr, 2); - long int i, j, valno=GET_LENGTH(val); + igraph_integer_t valno = Rf_xlength(val); SEXP names, newnames; SEXP res; - int keepno=0; - int *TODO; + igraph_integer_t keepno=0; + igraph_integer_t *TODO; igraph_function_pointer_t *funcs; int px = 0; /* Create the TODO list first */ PROTECT(names=GET_NAMES(val)); px++; - TODO=igraph_Calloc(valno, int); + TODO=igraph_Calloc(valno, igraph_integer_t); if (!TODO) { UNPROTECT(px); IGRAPH_ERROR("Cannot combine edge attributes", IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_free, TODO); - funcs=igraph_Calloc(valno, igraph_function_pointer_t); + funcs=IGRAPH_CALLOC(valno, igraph_function_pointer_t); if (!funcs) { UNPROTECT(px); IGRAPH_ERROR("Cannot combine edge attributes", IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_free, funcs); - for (i=0; iattr; SEXP toattr=newgraph->attr; SEXP eal=VECTOR_ELT(attr, 3); - long int i, j, ealno=GET_LENGTH(eal); + igraph_integer_t ealno = Rf_xlength(eal); SEXP names, newnames; SEXP res; - int keepno=0; - int *TODO; + igraph_integer_t keepno=0; + igraph_integer_t *TODO; igraph_function_pointer_t *funcs; int px = 0; /* Create the TODO list first */ PROTECT(names=GET_NAMES(eal)); px++; - TODO=igraph_Calloc(ealno, int); + TODO=IGRAPH_CALLOC(ealno, igraph_integer_t); if (!TODO) { UNPROTECT(px); IGRAPH_ERROR("Cannot combine edge attributes", @@ -2079,7 +2060,7 @@ int R_igraph_attribute_combine_edges(const igraph_t *graph, IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_free, funcs); - for (i=0; i 0) { - int count = R_igraph_warnings_count; R_igraph_warnings_count = 0; Rf_warning("%s", R_igraph_warning_reason); @@ -2305,7 +2285,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 @@ -2330,8 +2310,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, ".")); @@ -2347,11 +2326,7 @@ void checkInterruptFn(void *dummy) { R_CheckUserInterrupt(); } -int R_igraph_interrupt_handler(void *data) { - /* Temporary improvement for https://github.com/igraph/rigraph/issues/940 */ - static int iter = 0; - if (++iter < 16) return IGRAPH_SUCCESS; - iter = 0; +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 @@ -2372,7 +2347,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, double percent, void * data) { SEXP ec; int ecint; @@ -2392,7 +2367,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 l1 = PROTECT(Rf_install("getNamespace")); SEXP l2 = PROTECT(Rf_ScalarString(PROTECT(Rf_mkChar("igraph")))); SEXP l3 = PROTECT(Rf_lang2(l1, l2)); @@ -2420,9 +2395,7 @@ static void *R_igraph_altrep_from(SEXP vec, Rboolean writeable) { SEXP xp=Rf_findVar(Rf_install("igraph"), R_altrep_data1(vec)); igraph_t *g=(igraph_t*)(R_ExternalPtrAddr(xp)); - long int no_of_edges=igraph_ecount(g); - data=NEW_NUMERIC(no_of_edges); - memcpy(REAL(data), g->from.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); + data=R_igraph_vector_int_to_SEXP(&g->from); R_set_altrep_data2(vec, data); } @@ -2437,9 +2410,7 @@ static void *R_igraph_altrep_to(SEXP vec, Rboolean writeable) { SEXP xp=Rf_findVar(Rf_install("igraph"), R_altrep_data1(vec)); igraph_t *g=(igraph_t*)(R_ExternalPtrAddr(xp)); - long int no_of_edges=igraph_ecount(g); - data=NEW_NUMERIC(no_of_edges); - memcpy(REAL(data), g->to.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); + data=R_igraph_vector_int_to_SEXP(&g->to); R_set_altrep_data2(vec, data); } @@ -2520,19 +2491,22 @@ 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 result; + igraph_integer_t i, n=igraph_vector_int_size(v); - PROTECT(result=NEW_INTEGER(igraph_vector_int_size(v))); - igraph_vector_int_copy_to(v, INTEGER(result)); + PROTECT(result=NEW_NUMERIC(n)); + for (i=0; idata)[i]; } - UNPROTECT(1); + PROTECT(dim=NEW_INTEGER(2)); + /* TODO check that row and column counts fit in an int */ + INTEGER(dim)[0]=(int) igraph_matrix_int_nrow(m); + INTEGER(dim)[1]=(int) igraph_matrix_int_ncol(m); + SET_DIM(result, dim); + + UNPROTECT(2); return result; } +SEXP R_igraph_0ormatrix_int_to_SEXP(const igraph_matrix_int_t *m) { + if (!m) { + return R_NilValue; + } + return R_igraph_matrix_int_to_SEXP(m); +} + SEXP R_igraph_matrix_complex_to_SEXP(const igraph_matrix_complex_t *m) { SEXP result, dim; PROTECT(result=NEW_COMPLEX(igraph_matrix_complex_size(m))); igraph_matrix_complex_copy_to(m, (igraph_complex_t*) COMPLEX(result)); PROTECT(dim=NEW_INTEGER(2)); + /* TODO check that row and column counts fit in an int */ INTEGER(dim)[0]=(int) igraph_matrix_complex_nrow(m); INTEGER(dim)[1]=(int) igraph_matrix_complex_ncol(m); SET_DIM(result, dim); @@ -2731,6 +2690,7 @@ SEXP R_igraph_array3_to_SEXP(const igraph_array3_t *a) { PROTECT(result=NEW_NUMERIC(igraph_array3_size(a))); igraph_vector_copy_to(&a->data, REAL(result)); PROTECT(dim=NEW_INTEGER(3)); + /* TODO check that row, column and slice counts fit in an int */ INTEGER(dim)[0]=(int) igraph_array3_n(a, 1); INTEGER(dim)[1]=(int) igraph_array3_n(a, 2); INTEGER(dim)[2]=(int) igraph_array3_n(a, 3); @@ -2752,15 +2712,14 @@ SEXP R_igraph_0orarray3_to_SEXP(const igraph_array3_t *a) { } SEXP R_igraph_strvector_to_SEXP(const igraph_strvector_t *m) { - SEXP result; - long int i; - char *str; - long int len; + SEXP result;; + const char *str; + igraph_integer_t len; len=igraph_strvector_size(m); PROTECT(result=NEW_CHARACTER(len)); - for (i=0; ifrom); - igraph_vector_destroy(&graph->to); - igraph_vector_destroy(&graph->oi); - igraph_vector_destroy(&graph->ii); - igraph_vector_destroy(&graph->os); - igraph_vector_destroy(&graph->is); + igraph_destroy(graph); IGRAPH_FREE(graph); } @@ -2806,15 +2760,17 @@ static int restore_pointer(SEXP graph, igraph_t *g) { R_igraph_status_handler("Restore graph external pointer.\n", NULL); - igraph_vector_t from; - R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_from), &from); + igraph_vector_int_t from; + R_SEXP_to_vector_int_copy(VECTOR_ELT(graph, igraph_t_idx_from), &from); + IGRAPH_FINALLY(igraph_vector_int_destroy, &from); - igraph_vector_t to; - R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_to), &to); + igraph_vector_int_t to; + R_SEXP_to_vector_int_copy(VECTOR_ELT(graph, igraph_t_idx_to), &to); + IGRAPH_FINALLY(igraph_vector_int_destroy, &to); - igraph_vector_t edges; - igraph_integer_t no_of_edges=igraph_vector_size(&from); - IGRAPH_VECTOR_INIT_FINALLY(&edges, no_of_edges*2); + igraph_vector_int_t edges; + igraph_integer_t no_of_edges=igraph_vector_int_size(&from); + IGRAPH_VECTOR_INT_INIT_FINALLY(&edges, no_of_edges*2); for (igraph_integer_t i = 0; i < no_of_edges; ++i) { VECTOR(edges)[2*i] = VECTOR(from)[i]; @@ -2825,8 +2781,10 @@ static int restore_pointer(SEXP graph, igraph_t *g) { IGRAPH_FINALLY(igraph_destroy, g); IGRAPH_CHECK(igraph_add_edges(g, &edges, NULL)); - igraph_vector_destroy(&edges); - IGRAPH_FINALLY_CLEAN(2); /* +1 for g */ + igraph_vector_int_destroy(&from); + igraph_vector_int_destroy(&to); + igraph_vector_int_destroy(&edges); + IGRAPH_FINALLY_CLEAN(4); /* +1 for g */ return IGRAPH_SUCCESS; } @@ -2838,8 +2796,8 @@ void R_igraph_restore_pointer(SEXP graph) { } igraph_t *R_igraph_get_pointer(SEXP graph) { - if (GET_LENGTH(graph) != igraph_t_idx_max || !Rf_isEnvironment(R_igraph_graph_env(graph))) { - if (GET_LENGTH(graph) == 11) { + if (Rf_xlength(graph) != igraph_t_idx_max || !Rf_isEnvironment(R_igraph_graph_env(graph))) { + if (Rf_xlength(graph) == 11) { Rf_error("This graph was created by igraph < 0.2.\n Upgrading this format is not supported, sorry."); } Rf_error("This graph was created by a now unsupported old igraph version.\n Call upgrade_version() before using igraph functions on that object."); @@ -2886,7 +2844,7 @@ void R_igraph_set_from(SEXP rgraph, const igraph_t *graph) { SET_VECTOR_ELT(rgraph, igraph_t_idx_from, R_new_altrep(R_igraph_altrep_from_class, R_igraph_graph_env(rgraph), R_NilValue)); } -void R_igraph_get_from(SEXP graph, igraph_vector_t* from) { +void R_igraph_get_from(SEXP graph, igraph_vector_int_t* from) { igraph_t *pgraph=R_igraph_get_pointer(graph); *from = pgraph->from; } @@ -2895,7 +2853,7 @@ void R_igraph_set_to(SEXP rgraph, const igraph_t *graph) { SET_VECTOR_ELT(rgraph, igraph_t_idx_to, R_new_altrep(R_igraph_altrep_to_class, R_igraph_graph_env(rgraph), R_NilValue)); } -void R_igraph_get_to(SEXP graph, igraph_vector_t* to) { +void R_igraph_get_to(SEXP graph, igraph_vector_int_t* to) { igraph_t *pgraph=R_igraph_get_pointer(graph); *to = pgraph->to; } @@ -2903,8 +2861,6 @@ void R_igraph_get_to(SEXP graph, igraph_vector_t* to) { SEXP R_igraph_to_SEXP(const igraph_t *graph) { SEXP result; - long int no_of_nodes=igraph_vcount(graph); - long int no_of_edges=igraph_ecount(graph); PROTECT(result=NEW_LIST(igraph_t_idx_max)); R_igraph_set_n(result, graph); @@ -2927,13 +2883,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_vector_list_to_SEXP(const igraph_vector_list_t *list) { SEXP result; - long int i, n=igraph_vector_ptr_size(ptr); + igraph_integer_t 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")); @@ -3104,41 +3063,39 @@ 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_copy(VECTOR_ELT(shrg, 0), &hrg->left); + R_SEXP_to_vector_int_copy(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_copy(VECTOR_ELT(shrg, 3), &hrg->edges); + R_SEXP_to_vector_int_copy(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; } SEXP R_igraph_plfit_result_to_SEXP(const igraph_plfit_result_t *plfit) { SEXP result, names; - PROTECT(result=NEW_LIST(6)); + PROTECT(result=NEW_LIST(5)); SET_VECTOR_ELT(result, 0, Rf_ScalarLogical(plfit->continuous)); SET_VECTOR_ELT(result, 1, Rf_ScalarReal(plfit->alpha)); 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)); - PROTECT(names=NEW_CHARACTER(6)); + PROTECT(names=NEW_CHARACTER(5)); SET_STRING_ELT(names, 0, Rf_mkChar("continuous")); SET_STRING_ELT(names, 1, Rf_mkChar("alpha")); SET_STRING_ELT(names, 2, Rf_mkChar("xmin")); SET_STRING_ELT(names, 3, Rf_mkChar("logLik")); SET_STRING_ELT(names, 4, Rf_mkChar("KS.stat")); - SET_STRING_ELT(names, 5, Rf_mkChar("KS.p")); SET_NAMES(result, names); UNPROTECT(2); @@ -3167,9 +3124,94 @@ 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_I_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=REAL(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); + igraph_integer_t n=igraph_vector_ptr_size(sl); PROTECT(result=NEW_LIST(n)); PROTECT(names=NEW_CHARACTER(4)); @@ -3178,7 +3220,7 @@ SEXP R_igraph_sirlist_to_SEXP(const igraph_vector_ptr_t *sl) { SET_STRING_ELT(names, 2, Rf_mkChar("NI")); SET_STRING_ELT(names, 3, Rf_mkChar("NR")); - for (i=0; itimes); igraph_vector_int_destroy(&sir->no_s); @@ -3231,16 +3273,30 @@ SEXP R_igraph_sparsemat_to_SEXP_triplet(const igraph_sparsemat_t *sp) { SET_VECTOR_ELT(res, 1, NEW_INTEGER(2)); INTEGER(VECTOR_ELT(res, 1))[0] = (int) igraph_sparsemat_nrow(sp); INTEGER(VECTOR_ELT(res, 1))[1] = (int) igraph_sparsemat_ncol(sp); - SET_VECTOR_ELT(res, 2, NEW_INTEGER(nz)); - SET_VECTOR_ELT(res, 3, NEW_INTEGER(nz)); + SET_VECTOR_ELT(res, 2, NEW_NUMERIC(nz)); + SET_VECTOR_ELT(res, 3, NEW_NUMERIC(nz)); SET_VECTOR_ELT(res, 4, NEW_NUMERIC(nz)); if (nz > 0) { igraph_vector_int_t i, j; igraph_vector_t x; - igraph_vector_int_view(&i, INTEGER(VECTOR_ELT(res, 2)), nz); - igraph_vector_int_view(&j, INTEGER(VECTOR_ELT(res, 3)), nz); - igraph_vector_view(&x, REAL(VECTOR_ELT(res, 4)), nz); + igraph_vector_int_init(&i, nz); + IGRAPH_FINALLY(igraph_vector_int_destroy, &i); + + igraph_vector_int_init(&j, nz); + IGRAPH_FINALLY(igraph_vector_int_destroy, &j); + + igraph_vector_init(&x, nz); + IGRAPH_FINALLY(igraph_vector_destroy, &x); + igraph_sparsemat_getelements(sp, &j, &i, &x); + SET_VECTOR_ELT(res, 2, R_igraph_vector_int_to_SEXP(&i)); + SET_VECTOR_ELT(res, 3, R_igraph_vector_int_to_SEXP(&j)); + SET_VECTOR_ELT(res, 4, R_igraph_vector_to_SEXP(&x)); + + igraph_vector_int_destroy(&i); + igraph_vector_int_destroy(&j); + igraph_vector_destroy(&x); + IGRAPH_FINALLY_CLEAN(3); } PROTECT(names=NEW_CHARACTER(5)); @@ -3273,8 +3329,8 @@ SEXP R_igraph_sparsemat_to_SEXP_cc(const igraph_sparsemat_t *sp) { if (nz > 0) { igraph_vector_int_t i, p; igraph_vector_t x; - igraph_vector_int_view(&p, INTEGER(VECTOR_ELT(res, 2)), n+1); - igraph_vector_int_view(&i, INTEGER(VECTOR_ELT(res, 3)), nz); + R_SEXP_to_vector_int_copy(VECTOR_ELT(res, 2), &p); + R_SEXP_to_vector_int_copy(VECTOR_ELT(res, 3), &i); igraph_vector_view(&x, REAL(VECTOR_ELT(res, 4)), nz); igraph_sparsemat_getelements_sorted(sp, &i, &p, &x); } @@ -3309,80 +3365,73 @@ SEXP R_igraph_0orsparsemat_to_SEXP(const igraph_sparsemat_t *sp) { } int R_SEXP_to_igraph_adjlist(SEXP vectorlist, igraph_adjlist_t *ptr) { - int length=GET_LENGTH(vectorlist); - int i; + igraph_integer_t length = Rf_xlength(vectorlist); - ptr->length=length; - ptr->adjs = (igraph_vector_int_t*) R_alloc((size_t) length, - sizeof(igraph_vector_int_t)); - for (i=0; iadjs[i], INTEGER(vec), GET_LENGTH(vec)); - } - return 0; -} + igraph_integer_t n = Rf_xlength(vec); + double *svv=REAL(vec); -int R_igraph_SEXP_to_0orvectorlist(SEXP vectorlist, - igraph_vector_ptr_t *ptr) { - if (!Rf_isNull(vectorlist)) { - return R_igraph_SEXP_to_vectorlist(vectorlist, ptr); + igraph_vector_int_t *v=igraph_adjlist_get(ptr, i); + IGRAPH_CHECK(igraph_vector_int_resize(v, n)); + + for (igraph_integer_t j = 0; jstor_begin=vecs; + list->stor_end=list->stor_begin+length; + list->end=list->stor_end; + for (igraph_integer_t i=0; istor_begin=vecs; + list->stor_end=list->stor_begin+length; + list->end=list->stor_end; + for (igraph_integer_t 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)); + igraph_integer_t length = Rf_xlength(rval); + sv->stor_begin=(char**) R_alloc((size_t) length, sizeof(char*)); + sv->stor_end=sv->stor_begin+length; + sv->end=sv->stor_end; + for (igraph_integer_t i=0; istor_begin[i]=(char*) CHAR(STRING_ELT(rval, i)); } return 0; } 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++) { + igraph_strvector_init(sv, Rf_xlength(rval)); + for (igraph_integer_t i=0; istor_begin=REAL(sv); - v->stor_end=v->stor_begin+GET_LENGTH(sv); + v->stor_end=v->stor_begin + Rf_xlength(sv); v->end=v->stor_end; return 0; } int R_SEXP_to_vector_copy(SEXP sv, igraph_vector_t *v) { - return igraph_vector_init_copy(v, REAL(sv), GET_LENGTH(sv)); + return igraph_vector_init_array(v, REAL(sv), Rf_xlength(sv)); } int R_SEXP_to_vector_bool(SEXP sv, igraph_vector_bool_t *v) { v->stor_begin=LOGICAL(sv); - v->stor_end=v->stor_begin+GET_LENGTH(sv); + v->stor_end=v->stor_begin + Rf_xlength(sv); v->end=v->stor_end; return 0; } int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v) { - long int i, n=GET_LENGTH(sv); + igraph_integer_t n = Rf_xlength(sv); int *svv=LOGICAL(sv); igraph_vector_bool_init(v, n); - 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_copy(pakl, &akl->data); akl->nrow=INTEGER(GET_DIM(pakl))[0]; akl->ncol=INTEGER(GET_DIM(pakl))[1]; @@ -3468,7 +3515,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), Rf_xlength(pakl)); akl->nrow=INTEGER(GET_DIM(pakl))[0]; akl->ncol=INTEGER(GET_DIM(pakl))[1]; @@ -3477,14 +3524,14 @@ int R_SEXP_to_igraph_matrix_copy(SEXP pakl, igraph_matrix_t *akl) { int R_SEXP_to_vector_complex(SEXP pv, igraph_vector_complex_t *v) { v->stor_begin=(igraph_complex_t*) COMPLEX(pv); - v->stor_end=v->stor_begin+GET_LENGTH(pv); + v->stor_end=v->stor_begin + Rf_xlength(pv); v->end=v->stor_end; return 0; } 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), - GET_LENGTH(pv)); + igraph_vector_complex_init_array(v, (igraph_complex_t*) COMPLEX(pv), + Rf_xlength(pv)); return 0; } @@ -3496,9 +3543,9 @@ 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)); + Rf_xlength(pakl)); akl->nrow=INTEGER(GET_DIM(pakl))[0]; akl->ncol=INTEGER(GET_DIM(pakl))[1]; return 0; @@ -3515,7 +3562,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), Rf_xlength(rval)); a->n1=INTEGER(GET_DIM(rval))[0]; a->n2=INTEGER(GET_DIM(rval))[1]; a->n3=INTEGER(GET_DIM(rval))[2]; @@ -3547,11 +3594,11 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { * We have only vector type */ -int R_SEXP_to_igraph_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it) { +int R_SEXP_to_igraph_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it, igraph_vector_int_t *data) { + + R_SEXP_to_vector_int_copy(rit, data); + igraph_vs_vector(it, data); - 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))); return 0; } @@ -3559,11 +3606,11 @@ int R_SEXP_to_igraph_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it) { * We have only vector type */ -int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it) { +int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it, igraph_vector_int_t *data) { + + R_SEXP_to_vector_int_copy(rit, data); + igraph_es_vector(it, data); - 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))); return 0; } @@ -3778,16 +3825,16 @@ SEXP R_igraph_bliss_info_to_SEXP(const igraph_bliss_info_t *info) { SEXP R_igraph_copy_from(SEXP graph) { - igraph_vector_t from; + igraph_vector_int_t from; R_igraph_get_from(graph, &from); - return R_igraph_vector_to_SEXP(&from); + return R_igraph_vector_int_to_SEXP(&from); } SEXP R_igraph_copy_to(SEXP graph) { - igraph_vector_t to; + igraph_vector_int_t to; R_igraph_get_to(graph, &to); - return R_igraph_vector_to_SEXP(&to); + return R_igraph_vector_int_to_SEXP(&to); } SEXP R_igraph_copy_env(SEXP graph) @@ -3838,12 +3885,12 @@ SEXP R_igraph_mybracket3_set(SEXP graph, SEXP pidx1, SEXP pidx2, int idx2=INTEGER(pidx2)[0]-1; const char *name=CHAR(STRING_ELT(pname, 0)); SEXP attrs, names; - int i, n; + igraph_integer_t i, n; PROTECT(newgraph=Rf_duplicate(graph)); attrs=VECTOR_ELT(VECTOR_ELT(newgraph, idx1), idx2); names=PROTECT(Rf_getAttrib(attrs, R_NamesSymbol)); - n=Rf_length(attrs); + n=Rf_xlength(attrs); for (i=0; i100) { - distances_johnson(&g, &res, vs, to, pw, (igraph_neimode_t) mode, negw); + if (negw && mode != IGRAPH_ALL && Rf_xlength(pvids)>100) { + distances_johnson(&g, &res, vs, to, pw, mode, negw); } else if (negw) { - IGRAPH_R_CHECK(igraph_shortest_paths_bellman_ford(&g, &res, vs, to, pw, (igraph_neimode_t) mode)); + IGRAPH_R_CHECK(igraph_shortest_paths_bellman_ford(&g, &res, vs, to, pw, mode)); } else { /* This one chooses 'unweighted' if there are no weights */ - IGRAPH_R_CHECK(igraph_shortest_paths_dijkstra(&g, &res, vs, to, pw, (igraph_neimode_t) mode)); + IGRAPH_R_CHECK(igraph_shortest_paths_dijkstra(&g, &res, vs, to, pw, mode)); } break; case 1: /* unweighted */ - IGRAPH_R_CHECK(igraph_shortest_paths(&g, &res, vs, to, (igraph_neimode_t) mode)); + IGRAPH_R_CHECK(igraph_shortest_paths(&g, &res, vs, to, mode)); break; case 2: /* dijkstra */ - IGRAPH_R_CHECK(igraph_shortest_paths_dijkstra(&g, &res, vs, to, pw, (igraph_neimode_t) mode)); + IGRAPH_R_CHECK(igraph_shortest_paths_dijkstra(&g, &res, vs, to, pw, mode)); break; case 3: /* bellman-ford */ - IGRAPH_R_CHECK(igraph_shortest_paths_bellman_ford(&g, &res, vs, to, pw, (igraph_neimode_t) mode)); + IGRAPH_R_CHECK(igraph_shortest_paths_bellman_ford(&g, &res, vs, to, pw, mode)); break; case 4: /* johnson */ distances_johnson(&g, &res, vs, to, pw, mode, negw); @@ -4332,6 +4392,8 @@ SEXP R_igraph_shortest_paths(SEXP graph, SEXP pvids, SEXP pto, } PROTECT(result=R_igraph_matrix_to_SEXP(&res)); igraph_matrix_destroy(&res); + igraph_vector_int_destroy(&to_data); + igraph_vector_int_destroy(&vs_data); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4342,18 +4404,19 @@ 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_copy(pdimvector, &dimvector); IGRAPH_R_CHECK(igraph_lattice(&g, &dimvector, nei, directed, mutual, circular)); PROTECT(result=R_igraph_to_SEXP(&g)); IGRAPH_I_DESTROY(&g); + igraph_vector_int_destroy(&dimvector); UNPROTECT(1); return result; @@ -4367,7 +4430,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]; @@ -4376,9 +4439,11 @@ 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); - myoutseq=&outseq; + R_SEXP_to_vector_int_copy(poutseq, &outseq); + } else { + IGRAPH_R_CHECK(igraph_vector_int_init(&outseq, 0)); } + IGRAPH_FINALLY(igraph_vector_int_destroy, &outseq); if (!Rf_isNull(pstart)) { R_SEXP_to_igraph(pstart, &start); @@ -4387,6 +4452,8 @@ SEXP R_igraph_barabasi_game(SEXP pn, SEXP ppower, SEXP pm, SEXP poutseq, IGRAPH_R_CHECK(igraph_barabasi_game(&g, n, power, m, myoutseq, outpref, A, directed, algo, ppstart)); PROTECT(result=R_igraph_to_SEXP(&g)); + igraph_vector_int_destroy(&outseq); + IGRAPH_FINALLY_CLEAN(1); IGRAPH_I_DESTROY(&g); UNPROTECT(1); @@ -4402,16 +4469,17 @@ 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_copy(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)); + igraph_vector_int_destroy(&outseq); IGRAPH_I_DESTROY(&g); UNPROTECT(1); @@ -4446,7 +4514,7 @@ SEXP R_igraph_layout_fruchterman_reingold(SEXP graph, SEXP coords, igraph_matrix_init(&c_coords, 0, 0); } IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); - c_niter=INTEGER(niter)[0]; + c_niter=(igraph_integer_t) REAL(niter)[0]; c_start_temp=REAL(start_temp)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } if (!Rf_isNull(minx)) { R_SEXP_to_vector(minx, &c_minx); } @@ -4496,7 +4564,7 @@ SEXP R_igraph_layout_fruchterman_reingold_3d(SEXP graph, SEXP coords, igraph_matrix_init(&c_coords, 0, 0); } IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); - c_niter=INTEGER(niter)[0]; + c_niter=(igraph_integer_t) REAL(niter)[0]; c_start_temp=REAL(start_temp)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } if (!Rf_isNull(minx)) { R_SEXP_to_vector(minx, &c_minx); } @@ -4546,7 +4614,7 @@ SEXP R_igraph_layout_kamada_kawai(SEXP graph, SEXP coords, SEXP maxiter, igraph_matrix_init(&c_coords, 0, 0); } IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); - c_maxiter=INTEGER(maxiter)[0]; + c_maxiter=(igraph_integer_t) REAL(maxiter)[0]; c_epsilon=REAL(epsilon)[0]; c_kkconst=REAL(kkconst)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } @@ -4599,7 +4667,7 @@ SEXP R_igraph_layout_kamada_kawai_3d(SEXP graph, SEXP coords, SEXP maxiter, igraph_matrix_init(&c_coords, 0, 0); } IGRAPH_FINALLY(igraph_matrix_destroy, &c_coords); - c_maxiter=INTEGER(maxiter)[0]; + c_maxiter=(igraph_integer_t) REAL(maxiter)[0]; c_epsilon=REAL(epsilon)[0]; c_kkconst=REAL(kkconst)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } @@ -4716,10 +4784,9 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, igraph_t g; 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; - long int i; - igraph_vector_ptr_t ptrvec, ptrevec; + igraph_vector_int_t to_data; + igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); + igraph_vector_int_list_t list, elist; igraph_vector_t w, *pw=&w; igraph_bool_t negw=0; SEXP result, result1, result2, names; @@ -4727,31 +4794,19 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, igraph_bool_t edges=REAL(output)[0]==1 || REAL(output)[0]==2; 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; + int algo = (int) REAL(palgo)[0]; + igraph_vector_int_t predvec, inboundvec; - long int no=(long int) REAL(pno)[0]; + igraph_integer_t no = (igraph_integer_t) REAL(pno)[0]; R_SEXP_to_igraph(graph, &g); - R_SEXP_to_igraph_vs(pto, &g, &to); + R_SEXP_to_igraph_vs(pto, &g, &to, &to_data); if (verts) { - igraph_vector_ptr_init(&ptrvec, no); - vects=(igraph_vector_t*) R_alloc((size_t) GET_LENGTH(pto), - sizeof(igraph_vector_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 */ if (negw) { - IGRAPH_R_CHECK(igraph_get_shortest_paths_bellman_ford(&g, verts ? &ptrvec : 0, edges ? &ptrevec : 0, from, to, pw, (igraph_neimode_t) mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); + IGRAPH_R_CHECK(igraph_get_shortest_paths_bellman_ford(&g, verts ? &list : 0, edges ? &elist : 0, from, to, pw, mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); } else { /* This one chooses 'unweighted' if there are no weights */ - IGRAPH_R_CHECK(igraph_get_shortest_paths_dijkstra(&g, verts ? &ptrvec : 0, edges ? &ptrevec : 0, from, to, pw, (igraph_neimode_t) mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); + IGRAPH_R_CHECK(igraph_get_shortest_paths_dijkstra(&g, verts ? &list : 0, edges ? &elist : 0, from, to, pw, mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); } break; case 1: /* unweighted */ - IGRAPH_R_CHECK(igraph_get_shortest_paths(&g, verts ? &ptrvec : 0, edges ? &ptrevec : 0, from, to, (igraph_neimode_t) mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); + IGRAPH_R_CHECK(igraph_get_shortest_paths(&g, verts ? &list : 0, edges ? &elist : 0, from, to, mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); break; case 2: /* dijkstra */ - IGRAPH_R_CHECK(igraph_get_shortest_paths_dijkstra(&g, verts ? &ptrvec : 0, edges ? &ptrevec : 0, from, to, pw, (igraph_neimode_t) mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); + IGRAPH_R_CHECK(igraph_get_shortest_paths_dijkstra(&g, verts ? &list : 0, edges ? &elist : 0, from, to, pw, mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); break; case 3: /* bellman-ford */ - IGRAPH_R_CHECK(igraph_get_shortest_paths_bellman_ford(&g, verts ? &ptrvec : 0, edges ? &ptrevec : 0, from, to, pw, (igraph_neimode_t) mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); + IGRAPH_R_CHECK(igraph_get_shortest_paths_bellman_ford(&g, verts ? &list : 0, edges ? &elist : 0, from, to, pw, mode, pred ? &predvec : 0, inbound ? &inboundvec : 0)); break; } + igraph_vector_int_destroy(&to_data); + igraph_vs_destroy(&to); + PROTECT(result=NEW_LIST(4)); if (verts) { SET_VECTOR_ELT(result, 0, NEW_LIST(no)); result1=VECTOR_ELT(result, 0); - for (i=0; i0) { + if (Rf_xlength(ppredef)>0) { R_igraph_SEXP_to_strvector(ppredef, &predef); predefptr=&predef; } @@ -5510,7 +5543,7 @@ SEXP R_igraph_read_graph_lgl(SEXP pvfile, SEXP pnames, SEXP pweights, SEXP pdire SEXP result; #if HAVE_FMEMOPEN == 1 - file=fmemopen(RAW(pvfile), GET_LENGTH(pvfile), "r"); + file=fmemopen(RAW(pvfile), Rf_xlength(pvfile), "r"); #else file=fopen(CHAR(STRING_ELT(pvfile, 0)), "r"); #endif @@ -5574,7 +5607,7 @@ SEXP R_igraph_read_graph_pajek(SEXP pvfile) { SEXP result; #if HAVE_FMEMOPEN == 1 - file=fmemopen(RAW(pvfile), GET_LENGTH(pvfile), "r"); + file=fmemopen(RAW(pvfile), Rf_xlength(pvfile), "r"); #else file=fopen(CHAR(STRING_ELT(pvfile, 0)), "r"); #endif @@ -5596,21 +5629,15 @@ SEXP R_igraph_decompose(SEXP graph, SEXP pmode, SEXP pmaxcompno, igraph_connectedness_t mode = (igraph_connectedness_t) Rf_asInteger(pmode); igraph_integer_t maxcompno=(igraph_integer_t) REAL(pmaxcompno)[0]; igraph_integer_t minelements=(igraph_integer_t) REAL(pminelements)[0]; - igraph_vector_ptr_t comps; + igraph_graph_list_t comps; SEXP result; - long int i; R_SEXP_to_igraph(graph, &g); - igraph_vector_ptr_init(&comps, 0); - IGRAPH_FINALLY(igraph_vector_ptr_destroy, &comps); + igraph_graph_list_init(&comps, 0); + IGRAPH_FINALLY(igraph_graph_list_destroy, &comps); IGRAPH_R_CHECK(igraph_decompose(&g, &comps, mode, maxcompno, minelements)); - PROTECT(result=NEW_LIST(igraph_vector_ptr_size(&comps))); - for (i=0; ifun, data->graph, args, data->extra)); @@ -7819,10 +7804,10 @@ igraph_bool_t R_igraph_bfshandler(const igraph_t *graph, cres = Rf_asLogical(R_igraph_handle_safe_eval_result_in_env(result, data->rho)); UNPROTECT(4); - return cres; + return cres ? IGRAPH_STOP : IGRAPH_SUCCESS; } -SEXP R_igraph_bfs(SEXP graph, SEXP proot, SEXP proots, SEXP pneimode, +SEXP R_igraph_bfs(SEXP graph, SEXP proot, SEXP proots, SEXP pmode, SEXP punreachable, SEXP prestricted, SEXP porder, SEXP prank, SEXP pfather, SEXP ppred, SEXP psucc, SEXP pdist, @@ -7832,46 +7817,53 @@ 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_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 restricted; + igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); + 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_copy(proots, &roots); + } else { + igraph_vector_int_init(&roots, 0); } + IGRAPH_FINALLY(igraph_vector_int_destroy, &roots); + if (!Rf_isNull(prestricted)) { - R_SEXP_to_vector(prestricted, &restricted); + R_SEXP_to_vector_int_copy(prestricted, &restricted); + } else { + igraph_vector_int_init(&restricted, 0); } + IGRAPH_FINALLY(igraph_vector_int_destroy, &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; } @@ -7884,7 +7876,7 @@ SEXP R_igraph_bfs(SEXP graph, SEXP proot, SEXP proots, SEXP pneimode, p_cb_data = &cb_data; } - IGRAPH_R_CHECK(igraph_bfs(&g, root, Rf_isNull(proots) ? 0 : &roots, (igraph_neimode_t) neimode, unreachable, Rf_isNull(prestricted) ? 0 : &restricted, p_order, p_rank, p_father, p_pred, p_succ, p_dist, (igraph_bfshandler_t*) callback, p_cb_data)); + IGRAPH_R_CHECK(igraph_bfs(&g, root, Rf_isNull(proots) ? 0 : &roots, mode, unreachable, Rf_isNull(prestricted) ? 0 : &restricted, p_order, p_rank, p_father, p_pred, p_succ, p_dist, (igraph_bfshandler_t*) callback, p_cb_data)); PROTECT(result=NEW_LIST(8)); PROTECT(names=NEW_CHARACTER(8)); @@ -7895,37 +7887,42 @@ SEXP R_igraph_bfs(SEXP graph, SEXP proot, SEXP proots, SEXP pneimode, SET_STRING_ELT(names, 1, Rf_mkChar("mode")); SET_VECTOR_ELT(result, 1, NEW_CHARACTER(1)); - if (neimode==1) { + if (mode==IGRAPH_OUT) { SET_STRING_ELT(VECTOR_ELT(result, 1), 0, Rf_mkChar("out")); - } else if (neimode==2) { + } else if (mode==IGRAPH_IN) { SET_STRING_ELT(VECTOR_ELT(result, 1), 0, Rf_mkChar("in")); } else { SET_STRING_ELT(VECTOR_ELT(result, 1), 0, Rf_mkChar("all")); } 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; } + igraph_vector_int_destroy(&roots); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&restricted); + IGRAPH_FINALLY_CLEAN(1); + + 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; } @@ -7934,7 +7931,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, @@ -7959,27 +7956,26 @@ igraph_bool_t R_igraph_dfshandler(const igraph_t *graph, cres = Rf_asLogical(R_igraph_handle_safe_eval_result_in_env(result, data->rho)); UNPROTECT(4); - return cres; + return cres ? IGRAPH_STOP : IGRAPH_SUCCESS; } -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_integer_t vid, - igraph_integer_t dist, - void *extra) { +igraph_error_t R_igraph_dfshandler_out(const igraph_t *graph, + igraph_integer_t vid, + igraph_integer_t dist, + void *extra) { return R_igraph_dfshandler(graph, vid, dist, extra, 1); } -SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, +SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pmode, SEXP punreachable, SEXP porder, SEXP porder_out, SEXP pfather, SEXP pdist, SEXP pin_callback, SEXP pout_callback, SEXP pextra, SEXP prho) { @@ -7988,26 +7984,26 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, SEXP result, names; igraph_integer_t root=(igraph_integer_t) REAL(proot)[0]; - igraph_integer_t neimode=(igraph_integer_t) REAL(pneimode)[0]; + igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); 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)) { @@ -8025,7 +8021,7 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, out_callback=R_igraph_dfshandler_out; } - IGRAPH_R_CHECK(igraph_dfs(&g, root, (igraph_neimode_t) neimode, unreachable, p_order, p_order_out, p_father, p_dist, (igraph_dfshandler_t*) in_callback, (igraph_dfshandler_t*) out_callback, p_cb_data)); + IGRAPH_R_CHECK(igraph_dfs(&g, root, mode, unreachable, p_order, p_order_out, p_father, p_dist, (igraph_dfshandler_t*) in_callback, (igraph_dfshandler_t*) out_callback, p_cb_data)); PROTECT(result=NEW_LIST(6)); PROTECT(names=NEW_CHARACTER(6)); @@ -8036,22 +8032,22 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, SET_STRING_ELT(names, 1, Rf_mkChar("mode")); SET_VECTOR_ELT(result, 1, NEW_CHARACTER(1)); - if (neimode==1) { + if (mode==IGRAPH_OUT) { SET_STRING_ELT(VECTOR_ELT(result, 1), 0, Rf_mkChar("out")); - } else if (neimode==2) { + } else if (mode==IGRAPH_IN) { SET_STRING_ELT(VECTOR_ELT(result, 1), 0, Rf_mkChar("in")); } else { SET_STRING_ELT(VECTOR_ELT(result, 1), 0, Rf_mkChar("all")); } 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); @@ -8059,11 +8055,10 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, return result; } - 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; @@ -8074,31 +8069,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_SEXPp1(&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)); @@ -8128,8 +8123,8 @@ SEXP R_igraph_i_levc_arp(SEXP extP, SEXP extE, SEXP pv) { void *extra=R_ExternalPtrAddr(extE); SEXP res; - PROTECT(res=NEW_NUMERIC(GET_LENGTH(pv))); - fun(REAL(res), REAL(pv), GET_LENGTH(pv), extra); + PROTECT(res=NEW_NUMERIC(Rf_xlength(pv))); + fun(REAL(res), REAL(pv), Rf_xlength(pv), extra); UNPROTECT(1); return res; @@ -8142,13 +8137,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; @@ -8157,7 +8152,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)); @@ -8187,15 +8182,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; @@ -8213,24 +8208,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); - c_steps=INTEGER(steps)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + c_steps=(igraph_integer_t) REAL(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)) { @@ -8242,19 +8237,19 @@ 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)); REAL(modularity)[0]=c_modularity; 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); + PROTECT(eigenvectors=R_igraph_vector_list_to_SEXP(&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); @@ -8280,100 +8275,28 @@ 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_copy(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(&vp); + 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 */ @@ -8418,560 +8341,18 @@ 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_I_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_I_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_I_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_integer_t c_time_limit; igraph_bool_t c_qmap; igraph_bool_t c_qall_maps; SEXP iso; @@ -8983,50 +8364,57 @@ 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); + if (!Rf_isNull(domains)) { + R_igraph_SEXP_to_vector_int_list(domains, &c_domains); + } else { + igraph_vector_int_list_init(&c_domains, 0); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &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; } c_induced=LOGICAL(induced)[0]; - c_time_limit=INTEGER(time_limit)[0]; + c_time_limit=(igraph_integer_t) REAL(time_limit)[0]; /* Call igraph */ IGRAPH_R_CHECK(igraph_subisomorphic_lad(&c_pattern, &c_target, (Rf_isNull(domains) ? 0 : &c_domains), &c_iso, (Rf_isNull(map) ? 0 : &c_map), (Rf_isNull(maps) ? 0 : &c_maps), c_induced, c_time_limit)); /* Convert output */ + igraph_vector_int_list_destroy(&c_domains); + IGRAPH_FINALLY_CLEAN(1); PROTECT(result=NEW_LIST(3)); PROTECT(names=NEW_CHARACTER(3)); 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); @@ -9051,9 +8439,9 @@ 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; + igraph_integer_t c_niter; SEXP cliques; SEXP Mu; SEXP result, names; @@ -9061,23 +8449,23 @@ 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); } IGRAPH_FINALLY(igraph_vector_destroy, &c_Mu); - c_niter=INTEGER(niter)[0]; + c_niter=(igraph_integer_t) REAL(niter)[0]; /* Call igraph */ IGRAPH_R_CHECK(igraph_graphlets(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_cliques, &c_Mu, c_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_SEXPp1(&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); @@ -9100,7 +8488,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; @@ -9110,10 +8498,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); } @@ -9124,8 +8512,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_SEXPp1(&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); @@ -9141,11 +8529,10 @@ SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { return(result); } -int igraph_i_graphlets_project(const igraph_t *graph, - const igraph_vector_t *weights, - const igraph_vector_ptr_t *cliques, - igraph_vector_t *Mu, igraph_bool_t startMu, - int niter, int vid1); +igraph_error_t igraph_i_graphlets_project( + const igraph_t *graph, const igraph_vector_t *weights, + const igraph_vector_int_list_t *cliques, igraph_vector_t *Mu, igraph_bool_t startMu, + igraph_integer_t niter, igraph_integer_t vid1); /*-------------------------------------------/ / igraph_graphlets_project / @@ -9156,21 +8543,26 @@ 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; + igraph_integer_t c_niter; SEXP result; /* 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); + } else { + igraph_vector_int_list_init(&c_cliques, 0); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cliques); if (0 != R_SEXP_to_vector_copy(Mu, &c_Mu)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_vector_destroy, &c_Mu); - c_niter=INTEGER(niter)[0]; + c_niter=(igraph_integer_t) REAL(niter)[0]; /* TODO: Change igraph_i_graphlets_project to igraph_graphlets_project, because * we should not depend on non-public functions from igraph. @@ -9182,6 +8574,8 @@ SEXP R_igraph_graphlets_project(SEXP graph, SEXP weights, SEXP cliques, /* Convert output */ PROTECT(Mu=R_igraph_vector_to_SEXP(&c_Mu)); + igraph_vector_int_list_destroy(&c_cliques); + IGRAPH_FINALLY_CLEAN(1); igraph_vector_destroy(&c_Mu); IGRAPH_FINALLY_CLEAN(1); result=Mu; @@ -9220,7 +8614,7 @@ SEXP R_igraph_adjacency_spectral_embedding(SEXP graph, SEXP no, R_SEXP_to_vector(pweights, &weights); } c_which=INTEGER(pwhich)[0]; - c_no=INTEGER(no)[0]; + c_no=REAL(no)[0]; c_scaled=LOGICAL(scaled)[0]; if (0 != igraph_matrix_init(&c_X, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); @@ -9298,7 +8692,7 @@ SEXP R_igraph_laplacian_spectral_embedding(SEXP graph, SEXP no, /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); directed=igraph_is_directed(&c_graph); - c_no=INTEGER(no)[0]; + c_no=REAL(no)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } c_which=INTEGER(which)[0]; c_type=(igraph_laplacian_spectral_embedding_type_t) INTEGER(type)[0]; @@ -9356,10 +8750,10 @@ SEXP R_igraph_laplacian_spectral_embedding(SEXP graph, SEXP no, SEXP R_igraph_simple_interconnected_islands_game(SEXP islands_n, SEXP islands_size, SEXP islands_pin, SEXP n_inter) { igraph_t g; - igraph_integer_t a=INTEGER(islands_n)[0]; - igraph_integer_t b=INTEGER(islands_size)[0]; + igraph_integer_t a=REAL(islands_n)[0]; + igraph_integer_t b=REAL(islands_size)[0]; igraph_real_t c=REAL(islands_pin)[0]; - igraph_integer_t d=INTEGER(n_inter)[0]; + igraph_integer_t d=REAL(n_inter)[0]; SEXP result; IGRAPH_R_CHECK(igraph_simple_interconnected_islands_game(&g, a, b, c, d)); @@ -9370,16 +8764,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 */ @@ -9387,10 +8771,10 @@ 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]; + int which=INTEGER(pwhich)[0]; igraph_bool_t do_1=(which == 0 || which == 1); igraph_bool_t do_2=(which == 0 || which == 2); SEXP proj1; @@ -9402,17 +8786,17 @@ 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]; + c_probe1=REAL(probe1)[0]; /* Call igraph */ IGRAPH_R_CHECK(igraph_bipartite_projection(&c_graph, (Rf_isNull(types) ? 0 : &c_types), do_1 ? &c_proj1 : 0, do_2 ? &c_proj2 : 0, (Rf_isNull(multiplicity1) ? 0 : &c_multiplicity1), (Rf_isNull(multiplicity2) ? 0 : &c_multiplicity2), c_probe1)); @@ -9435,11 +8819,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); @@ -9456,41 +8840,21 @@ 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; igraph_vs_t vs; + igraph_vector_int_t vs_data; igraph_vit_t vit; - igraph_integer_t mode = (igraph_integer_t) REAL(pmode)[0]; + igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); SEXP result; size_t i, n; igraph_lazy_adjlist_t adjlist; R_SEXP_to_igraph(pgraph, &graph); - R_SEXP_to_igraph_vs(pv, &graph, &vs); + R_SEXP_to_igraph_vs(pv, &graph, &vs, &vs_data); IGRAPH_FINALLY(igraph_vs_destroy, &vs); + IGRAPH_FINALLY(igraph_vector_int_destroy, &vs_data); igraph_vit_create(&graph, vs, &vit); IGRAPH_FINALLY(igraph_vit_destroy, &vit); @@ -9507,7 +8871,7 @@ SEXP R_igraph_adjacent_vertices(SEXP pgraph, SEXP pv, SEXP pmode) { for (IGRAPH_VIT_RESET(vit), i=0; !IGRAPH_VIT_END(vit); IGRAPH_VIT_NEXT(vit), i++) { - long int vid = IGRAPH_VIT_GET(vit); + igraph_integer_t vid = IGRAPH_VIT_GET(vit); igraph_vector_int_t *neis = igraph_lazy_adjlist_get(&adjlist, vid); SET_VECTOR_ELT(result, i, R_igraph_vector_int_to_SEXP(neis)); } @@ -9515,7 +8879,8 @@ SEXP R_igraph_adjacent_vertices(SEXP pgraph, SEXP pv, SEXP pmode) { igraph_lazy_adjlist_destroy(&adjlist); igraph_vit_destroy(&vit); igraph_vs_destroy(&vs); - IGRAPH_FINALLY_CLEAN(3); + igraph_vector_int_destroy(&vs_data); + IGRAPH_FINALLY_CLEAN(4); UNPROTECT(1); return result; @@ -9525,15 +8890,17 @@ SEXP R_igraph_incident_edges(SEXP pgraph, SEXP pe, SEXP pmode) { igraph_t graph; igraph_vs_t vs; + igraph_vector_int_t vs_data; igraph_vit_t vit; - igraph_integer_t mode = (igraph_integer_t) REAL(pmode)[0]; + igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); SEXP result; size_t i, n; igraph_lazy_inclist_t adjlist; R_SEXP_to_igraph(pgraph, &graph); - R_SEXP_to_igraph_vs(pe, &graph, &vs); + R_SEXP_to_igraph_vs(pe, &graph, &vs, &vs_data); IGRAPH_FINALLY(igraph_vs_destroy, &vs); + IGRAPH_FINALLY(igraph_vector_int_destroy, &vs_data); igraph_vit_create(&graph, vs, &vit); IGRAPH_FINALLY(igraph_vit_destroy, &vit); @@ -9546,7 +8913,7 @@ SEXP R_igraph_incident_edges(SEXP pgraph, SEXP pe, SEXP pmode) { for (IGRAPH_VIT_RESET(vit), i=0; !IGRAPH_VIT_END(vit); IGRAPH_VIT_NEXT(vit), i++) { - long int eid = IGRAPH_VIT_GET(vit); + igraph_integer_t eid = IGRAPH_VIT_GET(vit); igraph_vector_int_t *neis = igraph_lazy_inclist_get(&adjlist, eid); SET_VECTOR_ELT(result, i, R_igraph_vector_int_to_SEXP(neis)); } @@ -9554,7 +8921,8 @@ SEXP R_igraph_incident_edges(SEXP pgraph, SEXP pe, SEXP pmode) { igraph_lazy_inclist_destroy(&adjlist); igraph_vit_destroy(&vit); igraph_vs_destroy(&vs); - IGRAPH_FINALLY_CLEAN(3); + igraph_vector_int_destroy(&vs_data); + IGRAPH_FINALLY_CLEAN(4); UNPROTECT(1); return result; @@ -9585,8 +8953,8 @@ SEXP R_igraph_incident_edges(SEXP pgraph, SEXP pe, SEXP pmode) { /* ---------------------------------------------------------------C */ int igraphhcass2(int n, const int *ia, const int *ib, - int *iorder, int *iia, - int *iib) { + int *iorder, igraph_integer_t *iia, + igraph_integer_t *iib) { /* System generated locals */ int i__1, i__2, i__3; @@ -9695,18 +9063,18 @@ int igraphhcass2(int n, const int *ia, const int *ib, SEXP R_igraph_get_all_simple_paths_pp(SEXP vector) { SEXP result; - int i, no=0, n=GET_LENGTH(vector); - int *vec=INTEGER(vector), *p=vec, *pp=vec; - for (i=0; i #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; } @@ -91,19 +89,29 @@ static igraph_real_t igraph_rng_R_get_exp(void *state, igraph_real_t rate) { return scale * exp_rand(); } +static igraph_real_t igraph_rng_R_get_gamma(void *state, igraph_real_t shape, igraph_real_t scale) { + return Rf_rgamma(shape, scale); +} + +static igraph_real_t igraph_rng_R_get_pois(void *state, igraph_real_t rate) { + return Rf_rpois(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= */ igraph_rng_R_get_gamma, + /* get_pois= */ igraph_rng_R_get_pois }; igraph_rng_t igraph_rng_R_instance; diff --git a/src/sources.mk b/src/sources.mk new file mode 100644 index 00000000000..7d6b18abc52 --- /dev/null +++ b/src/sources.mk @@ -0,0 +1 @@ +SOURCES=init.o cpp11.o rinterface_extra.o cpprinterface.o lazyeval.o rinterface.o rrandom.o vendor/io/dl-parser.o vendor/io/ncol-lexer.o vendor/io/gml-parser.o vendor/io/ncol-parser.o vendor/io/gml-lexer.o vendor/io/dl-lexer.o vendor/io/lgl-parser.o vendor/io/lgl-lexer.o vendor/io/pajek-lexer.o vendor/io/pajek-parser.o vendor/cigraph/src/version.o vendor/cigraph/src/io/parse_utils.o vendor/cigraph/src/io/dl.o vendor/cigraph/src/io/edgelist.o vendor/cigraph/src/io/dimacs.o vendor/cigraph/src/io/gml.o vendor/cigraph/src/io/graphml.o vendor/cigraph/src/io/ncol.o vendor/cigraph/src/io/dot.o vendor/cigraph/src/io/lgl.o vendor/cigraph/src/io/pajek.o vendor/cigraph/src/io/leda.o vendor/cigraph/src/io/gml-tree.o vendor/cigraph/src/io/graphdb.o vendor/cigraph/src/misc/degree_sequence.o vendor/cigraph/src/misc/feedback_arc_set.o vendor/cigraph/src/misc/cocitation.o vendor/cigraph/src/misc/scan.o vendor/cigraph/src/misc/embedding.o vendor/cigraph/src/misc/power_law_fit.o vendor/cigraph/src/misc/cycle_bases.o vendor/cigraph/src/misc/mixing.o vendor/cigraph/src/misc/motifs.o vendor/cigraph/src/misc/graphicality.o vendor/cigraph/src/misc/matching.o vendor/cigraph/src/misc/order_cycle.o vendor/cigraph/src/misc/spanning_trees.o vendor/cigraph/src/misc/sir.o vendor/cigraph/src/misc/bipartite.o vendor/cigraph/src/misc/chordality.o vendor/cigraph/src/misc/microscopic_update.o vendor/cigraph/src/misc/coloring.o vendor/cigraph/src/misc/other.o vendor/cigraph/src/misc/conversion.o vendor/cigraph/src/hrg/hrg.o vendor/cigraph/src/hrg/hrg_types.o vendor/cigraph/src/isomorphism/lad.o vendor/cigraph/src/isomorphism/queries.o vendor/cigraph/src/isomorphism/isoclasses.o vendor/cigraph/src/isomorphism/isomorphism_misc.o vendor/cigraph/src/isomorphism/vf2.o vendor/cigraph/src/isomorphism/bliss.o vendor/cigraph/src/isomorphism/bliss/heap.o vendor/cigraph/src/isomorphism/bliss/uintseqhash.o vendor/cigraph/src/isomorphism/bliss/partition.o vendor/cigraph/src/isomorphism/bliss/graph.o vendor/cigraph/src/isomorphism/bliss/utils.o vendor/cigraph/src/isomorphism/bliss/orbit.o vendor/cigraph/src/isomorphism/bliss/defs.o vendor/cigraph/src/connectivity/cohesive_blocks.o vendor/cigraph/src/connectivity/separators.o vendor/cigraph/src/connectivity/components.o vendor/cigraph/src/properties/degrees.o vendor/cigraph/src/properties/triangles.o vendor/cigraph/src/properties/basic_properties.o vendor/cigraph/src/properties/girth.o vendor/cigraph/src/properties/loops.o vendor/cigraph/src/properties/constraint.o vendor/cigraph/src/properties/convergence_degree.o vendor/cigraph/src/properties/ecc.o vendor/cigraph/src/properties/neighborhood.o vendor/cigraph/src/properties/dag.o vendor/cigraph/src/properties/multiplicity.o vendor/cigraph/src/properties/spectral.o vendor/cigraph/src/properties/perfect.o vendor/cigraph/src/properties/trees.o vendor/cigraph/src/games/growing_random.o vendor/cigraph/src/games/citations.o vendor/cigraph/src/games/establishment.o vendor/cigraph/src/games/watts_strogatz.o vendor/cigraph/src/games/tree.o vendor/cigraph/src/games/dotproduct.o vendor/cigraph/src/games/degree_sequence.o vendor/cigraph/src/games/erdos_renyi.o vendor/cigraph/src/games/static_fitness.o vendor/cigraph/src/games/preference.o vendor/cigraph/src/games/recent_degree.o vendor/cigraph/src/games/callaway_traits.o vendor/cigraph/src/games/grg.o vendor/cigraph/src/games/k_regular.o vendor/cigraph/src/games/correlated.o vendor/cigraph/src/games/barabasi.o vendor/cigraph/src/games/sbm.o vendor/cigraph/src/games/islands.o vendor/cigraph/src/games/forestfire.o vendor/cigraph/src/games/degree_sequence_vl/gengraph_graph_molloy_optimized.o vendor/cigraph/src/games/degree_sequence_vl/gengraph_degree_sequence.o vendor/cigraph/src/games/degree_sequence_vl/gengraph_graph_molloy_hash.o vendor/cigraph/src/games/degree_sequence_vl/gengraph_random.o vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.o vendor/cigraph/src/core/printing.o vendor/cigraph/src/core/interruption.o vendor/cigraph/src/core/vector_ptr.o vendor/cigraph/src/core/memory.o vendor/cigraph/src/core/sparsemat.o vendor/cigraph/src/core/error.o vendor/cigraph/src/core/genheap.o vendor/cigraph/src/core/progress.o vendor/cigraph/src/core/statusbar.o vendor/cigraph/src/core/heap.o vendor/cigraph/src/core/indheap.o vendor/cigraph/src/core/grid.o vendor/cigraph/src/core/trie.o vendor/cigraph/src/core/stack.o vendor/cigraph/src/core/estack.o vendor/cigraph/src/core/buckets.o vendor/cigraph/src/core/vector_list.o vendor/cigraph/src/core/matrix_list.o vendor/cigraph/src/core/fixed_vectorlist.o vendor/cigraph/src/core/strvector.o vendor/cigraph/src/core/marked_queue.o vendor/cigraph/src/core/dqueue.o vendor/cigraph/src/core/array.o vendor/cigraph/src/core/cutheap.o vendor/cigraph/src/core/matrix.o vendor/cigraph/src/core/psumtree.o vendor/cigraph/src/core/vector.o vendor/cigraph/src/core/set.o vendor/cigraph/src/internal/glpk_support.o vendor/cigraph/src/internal/hacks.o vendor/cigraph/src/internal/lsap.o vendor/cigraph/src/internal/zeroin.o vendor/cigraph/src/internal/utils.o vendor/cigraph/src/internal/qsort_r.o vendor/cigraph/src/internal/qsort.o vendor/cigraph/src/operators/disjoint_union.o vendor/cigraph/src/operators/subgraph.o vendor/cigraph/src/operators/intersection.o vendor/cigraph/src/operators/simplify.o vendor/cigraph/src/operators/compose.o vendor/cigraph/src/operators/complementer.o vendor/cigraph/src/operators/rewire_edges.o vendor/cigraph/src/operators/union.o vendor/cigraph/src/operators/permute.o vendor/cigraph/src/operators/misc_internal.o vendor/cigraph/src/operators/contract.o vendor/cigraph/src/operators/add_edge.o vendor/cigraph/src/operators/reverse.o vendor/cigraph/src/operators/difference.o vendor/cigraph/src/operators/connect_neighborhood.o vendor/cigraph/src/operators/rewire.o vendor/cigraph/src/layout/large_graph.o vendor/cigraph/src/layout/sugiyama.o vendor/cigraph/src/layout/circular.o vendor/cigraph/src/layout/layout_bipartite.o vendor/cigraph/src/layout/graphopt.o vendor/cigraph/src/layout/fruchterman_reingold.o vendor/cigraph/src/layout/kamada_kawai.o vendor/cigraph/src/layout/davidson_harel.o vendor/cigraph/src/layout/merge_dla.o vendor/cigraph/src/layout/gem.o vendor/cigraph/src/layout/layout_random.o vendor/cigraph/src/layout/reingold_tilford.o vendor/cigraph/src/layout/merge_grid.o vendor/cigraph/src/layout/umap.o vendor/cigraph/src/layout/mds.o vendor/cigraph/src/layout/layout_grid.o vendor/cigraph/src/layout/drl/drl_graph_3d.o vendor/cigraph/src/layout/drl/drl_layout_3d.o vendor/cigraph/src/layout/drl/drl_parse.o vendor/cigraph/src/layout/drl/DensityGrid_3d.o vendor/cigraph/src/layout/drl/drl_layout.o vendor/cigraph/src/layout/drl/DensityGrid.o vendor/cigraph/src/layout/drl/drl_graph.o vendor/cigraph/src/community/louvain.o vendor/cigraph/src/community/optimal_modularity.o vendor/cigraph/src/community/leading_eigenvector.o vendor/cigraph/src/community/edge_betweenness.o vendor/cigraph/src/community/community_misc.o vendor/cigraph/src/community/leiden.o vendor/cigraph/src/community/modularity.o vendor/cigraph/src/community/label_propagation.o vendor/cigraph/src/community/fast_modularity.o vendor/cigraph/src/community/voronoi.o vendor/cigraph/src/community/fluid.o vendor/cigraph/src/community/spinglass/pottsmodel_2.o vendor/cigraph/src/community/spinglass/NetRoutines.o vendor/cigraph/src/community/spinglass/clustertool.o vendor/cigraph/src/community/spinglass/NetDataTypes.o vendor/cigraph/src/community/walktrap/walktrap_heap.o vendor/cigraph/src/community/walktrap/walktrap_graph.o vendor/cigraph/src/community/walktrap/walktrap_communities.o vendor/cigraph/src/community/walktrap/walktrap.o vendor/cigraph/src/community/infomap/infomap.o vendor/cigraph/src/community/infomap/infomap_Greedy.o vendor/cigraph/src/community/infomap/infomap_FlowGraph.o vendor/cigraph/src/paths/astar.o vendor/cigraph/src/paths/widest_paths.o vendor/cigraph/src/paths/random_walk.o vendor/cigraph/src/paths/distances.o vendor/cigraph/src/paths/floyd_warshall.o vendor/cigraph/src/paths/shortest_paths.o vendor/cigraph/src/paths/eulerian.o vendor/cigraph/src/paths/johnson.o vendor/cigraph/src/paths/bellman_ford.o vendor/cigraph/src/paths/voronoi.o vendor/cigraph/src/paths/unweighted.o vendor/cigraph/src/paths/all_shortest_paths.o vendor/cigraph/src/paths/sparsifier.o vendor/cigraph/src/paths/dijkstra.o vendor/cigraph/src/paths/simple_paths.o vendor/cigraph/src/paths/histogram.o vendor/cigraph/src/flow/flow.o vendor/cigraph/src/flow/st-cuts.o vendor/cigraph/src/flow/flow_conversion.o vendor/cigraph/src/math/utils.o vendor/cigraph/src/math/safe_intop.o vendor/cigraph/src/math/complex.o vendor/cigraph/src/constructors/regular.o vendor/cigraph/src/constructors/de_bruijn.o vendor/cigraph/src/constructors/basic_constructors.o vendor/cigraph/src/constructors/generalized_petersen.o vendor/cigraph/src/constructors/lattices.o vendor/cigraph/src/constructors/adjacency.o vendor/cigraph/src/constructors/famous.o vendor/cigraph/src/constructors/atlas.o vendor/cigraph/src/constructors/linegraph.o vendor/cigraph/src/constructors/kautz.o vendor/cigraph/src/constructors/circulant.o vendor/cigraph/src/constructors/lcf.o vendor/cigraph/src/constructors/trees.o vendor/cigraph/src/constructors/full.o vendor/cigraph/src/constructors/prufer.o vendor/cigraph/src/graph/basic_query.o vendor/cigraph/src/graph/type_indexededgelist.o vendor/cigraph/src/graph/graph_list.o vendor/cigraph/src/graph/caching.o vendor/cigraph/src/graph/type_common.o vendor/cigraph/src/graph/adjlist.o vendor/cigraph/src/graph/cattributes.o vendor/cigraph/src/graph/attributes.o vendor/cigraph/src/graph/visitors.o vendor/cigraph/src/graph/iterators.o vendor/cigraph/src/random/rng_pcg64.o vendor/cigraph/src/random/rng_glibc2.o vendor/cigraph/src/random/rng_pcg32.o vendor/cigraph/src/random/rng_mt19937.o vendor/cigraph/src/random/random.o vendor/cigraph/src/linalg/eigen.o vendor/cigraph/src/linalg/lapack.o vendor/cigraph/src/linalg/arpack.o vendor/cigraph/src/linalg/blas.o vendor/cigraph/src/centrality/centrality_other.o vendor/cigraph/src/centrality/centralization.o vendor/cigraph/src/centrality/hub_authority.o vendor/cigraph/src/centrality/prpack.o vendor/cigraph/src/centrality/pagerank.o vendor/cigraph/src/centrality/coreness.o vendor/cigraph/src/centrality/closeness.o vendor/cigraph/src/centrality/eigenvector.o vendor/cigraph/src/centrality/truss.o vendor/cigraph/src/centrality/betweenness.o vendor/cigraph/src/centrality/prpack/prpack_preprocessed_gs_graph.o vendor/cigraph/src/centrality/prpack/prpack_preprocessed_ge_graph.o vendor/cigraph/src/centrality/prpack/prpack_utils.o vendor/cigraph/src/centrality/prpack/prpack_igraph_graph.o vendor/cigraph/src/centrality/prpack/prpack_result.o vendor/cigraph/src/centrality/prpack/prpack_base_graph.o vendor/cigraph/src/centrality/prpack/prpack_solver.o vendor/cigraph/src/centrality/prpack/prpack_preprocessed_scc_graph.o vendor/cigraph/src/centrality/prpack/prpack_preprocessed_schur_graph.o vendor/cigraph/src/cliques/maximal_cliques.o vendor/cigraph/src/cliques/glet.o vendor/cigraph/src/cliques/cliques.o vendor/cigraph/src/cliques/cliquer_wrapper.o vendor/cigraph/src/cliques/cliquer/cliquer_graph.o vendor/cigraph/src/cliques/cliquer/reorder.o vendor/cigraph/src/cliques/cliquer/cliquer.o vendor/cigraph/vendor/plfit/options.o vendor/cigraph/vendor/plfit/lbfgs.o vendor/cigraph/vendor/plfit/mt.o vendor/cigraph/vendor/plfit/gss.o vendor/cigraph/vendor/plfit/rbinom.o vendor/cigraph/vendor/plfit/plfit_error.o vendor/cigraph/vendor/plfit/hzeta.o vendor/cigraph/vendor/plfit/plfit.o vendor/cigraph/vendor/plfit/platform.o vendor/cigraph/vendor/plfit/sampling.o vendor/cigraph/vendor/plfit/kolmogorov.o vendor/cigraph/vendor/cs/cs_post.o vendor/cigraph/vendor/cs/cs_updown.o vendor/cigraph/vendor/cs/cs_amd.o vendor/cigraph/vendor/cs/cs_happly.o vendor/cigraph/vendor/cs/cs_pinv.o vendor/cigraph/vendor/cs/cs_droptol.o vendor/cigraph/vendor/cs/cs_cumsum.o vendor/cigraph/vendor/cs/cs_permute.o vendor/cigraph/vendor/cs/cs_counts.o vendor/cigraph/vendor/cs/cs_qrsol.o vendor/cigraph/vendor/cs/cs_lu.o vendor/cigraph/vendor/cs/cs_dropzeros.o vendor/cigraph/vendor/cs/cs_tdfs.o vendor/cigraph/vendor/cs/cs_entry.o vendor/cigraph/vendor/cs/cs_chol.o vendor/cigraph/vendor/cs/cs_ltsolve.o vendor/cigraph/vendor/cs/cs_cholsol.o vendor/cigraph/vendor/cs/cs_dfs.o vendor/cigraph/vendor/cs/cs_add.o vendor/cigraph/vendor/cs/cs_usolve.o vendor/cigraph/vendor/cs/cs_pvec.o vendor/cigraph/vendor/cs/cs_ereach.o vendor/cigraph/vendor/cs/cs_etree.o vendor/cigraph/vendor/cs/cs_gaxpy.o vendor/cigraph/vendor/cs/cs_spsolve.o vendor/cigraph/vendor/cs/cs_randperm.o vendor/cigraph/vendor/cs/cs_ipvec.o vendor/cigraph/vendor/cs/cs_house.o vendor/cigraph/vendor/cs/cs_qr.o vendor/cigraph/vendor/cs/cs_print.o vendor/cigraph/vendor/cs/cs_maxtrans.o vendor/cigraph/vendor/cs/cs_dmperm.o vendor/cigraph/vendor/cs/cs_utsolve.o vendor/cigraph/vendor/cs/cs_lusol.o vendor/cigraph/vendor/cs/cs_symperm.o vendor/cigraph/vendor/cs/cs_scatter.o vendor/cigraph/vendor/cs/cs_reach.o vendor/cigraph/vendor/cs/cs_dupl.o vendor/cigraph/vendor/cs/cs_transpose.o vendor/cigraph/vendor/cs/cs_leaf.o vendor/cigraph/vendor/cs/cs_scc.o vendor/cigraph/vendor/cs/cs_lsolve.o vendor/cigraph/vendor/cs/cs_util.o vendor/cigraph/vendor/cs/cs_compress.o vendor/cigraph/vendor/cs/cs_fkeep.o vendor/cigraph/vendor/cs/cs_load.o vendor/cigraph/vendor/cs/cs_norm.o vendor/cigraph/vendor/cs/cs_sqr.o vendor/cigraph/vendor/cs/cs_malloc.o vendor/cigraph/vendor/cs/cs_multiply.o vendor/cigraph/vendor/cs/cs_schol.o vendor/cigraph/vendor/pcg/pcg-rngs-64.o vendor/cigraph/vendor/pcg/pcg-output-32.o vendor/cigraph/vendor/pcg/pcg-advance-128.o vendor/cigraph/vendor/pcg/pcg-advance-64.o vendor/cigraph/vendor/pcg/pcg-rngs-128.o vendor/cigraph/vendor/pcg/pcg-output-128.o vendor/cigraph/vendor/pcg/pcg-output-64.o vendor/arpack/dsaitr.o vendor/arpack/dnaupd.o vendor/arpack/dstqrb.o vendor/arpack/dgetv0.o vendor/arpack/dsapps.o vendor/arpack/dngets.o vendor/arpack/dnaitr.o vendor/arpack/dnaup2.o vendor/arpack/dnconv.o vendor/arpack/dstats.o vendor/arpack/dsortc.o vendor/arpack/dneigh.o vendor/arpack/dnapps.o vendor/arpack/dneupd.o vendor/arpack/dsesrt.o vendor/arpack/dsortr.o vendor/arpack/dvout.o vendor/arpack/dsaup2.o vendor/arpack/dsconv.o vendor/arpack/wrap.o vendor/arpack/dseigt.o vendor/arpack/dlaqrb.o vendor/arpack/dmout.o vendor/arpack/dstatn.o vendor/arpack/ivout.o vendor/arpack/dsgets.o vendor/arpack/second.o vendor/arpack/dsaupd.o vendor/arpack/dseupd.o vendor/mini-gmp/mini-gmp.o vendor/simpleraytracer/Triangle.o vendor/simpleraytracer/Light.o vendor/simpleraytracer/unit_limiter.o vendor/simpleraytracer/Ray.o vendor/simpleraytracer/RayTracer.o vendor/simpleraytracer/Point.o vendor/simpleraytracer/Color.o vendor/simpleraytracer/RIgraphRay.o vendor/simpleraytracer/Sphere.o vendor/simpleraytracer/Shape.o vendor/simpleraytracer/RayVector.o vendor/uuid/isnull.o vendor/uuid/clear.o vendor/uuid/unparse.o vendor/uuid/compare.o vendor/uuid/R.o vendor/uuid/pack.o vendor/uuid/gen_uuid.o vendor/uuid/unpack.o vendor/uuid/parse.o vendor/uuid/copy.o diff --git a/src/vendor/cigraph/.all-contributorsrc b/src/vendor/cigraph/.all-contributorsrc index 9c26f453ded..6137d64398c 100644 --- a/src/vendor/cigraph/.all-contributorsrc +++ b/src/vendor/cigraph/.all-contributorsrc @@ -513,6 +513,15 @@ "contributions": [ "code" ] + }, + { + "login": "larah19", + "name": "larah19", + "avatar_url": "https://avatars.githubusercontent.com/u/54937363?v=4", + "profile": "https://github.com/larah19", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7 diff --git a/src/vendor/cigraph/CHANGELOG.md b/src/vendor/cigraph/CHANGELOG.md index c82f17b3ab0..7856bb6972d 100644 --- a/src/vendor/cigraph/CHANGELOG.md +++ b/src/vendor/cigraph/CHANGELOG.md @@ -2,9 +2,13 @@ ## [master] +## [0.10.8] - 2023-11-17 + ### Added - `igraph_joint_degree_matrix()` computes the joint degree matrix, i.e. counts connections between vertices of different degrees. (PR #2407 by Lára Margrét Hólmfríðardóttir @larah19) + - `igraph_joint_degree_distribution()` computes the joint distribution of degrees at either end of edges. + - `igraph_joint_type_distribution()` computes the joint distribution of vertex categories at either end of edges, i.e. the mixing matrix. - `igraph_degree_correlation_vector()` computes the degree correlation function and its various directed generalizations. ### Changed @@ -23,6 +27,10 @@ - `igraph_full()`, `igraph_full_citation()`, `igraph_full_multipartite()` and `igraph_turan()` are now interruptible. - `igraph_avg_nearest_neighbor_degree()` did not compute `knnk` correctly in the weighted case. - Fixed variadic arguments of invalid types, which could cause incorrect behaviour with `igraph_matrix_print()`, as well as test suite failures, on some platforms. 32-bit x86 was affected when setting `IGRAPH_INTEGER_SIZE` to 64. + - `igraph_subisomorphic_lad()` now returns a single null map when the pattern is the null graph. + - `igraph_community_spinglass()` now checks its parameters more carefully. + - `igraph_similarity_dice_pairs()` and `igraph_similarity_jaccard_pairs()` now validate vertex IDs. + - `igraph_maxflow()` now returns an error code if the source and target vertices are the same. It used to get stuck in an infinite loop in earlier versions when the `flow` argument was non-NULL. ### Other @@ -711,6 +719,7 @@ Some of the highlights are: incorrect (it was always zero). This is now fixed. - `igraph_correlated_game()` would return incorrect results, or exhaust the memory, for most input graphs that were not generated with `igraph_erdos_renyi_game_gnp()`. + - `igraph_community_label_propagation` incorrectly did not result in all labels being dominant (issue #1963, fixed in PR #1966). ### Other @@ -1234,7 +1243,8 @@ Some of the highlights are: - Provide proper support for Windows, using `__declspec(dllexport)` and `__declspec(dllimport)` for `DLL`s and static usage by using `#define IGRAPH_STATIC 1`. - Provided integer versions of `dqueue` and `stack` data types. -[master]: https://github.com/igraph/igraph/compare/0.10.7..master +[master]: https://github.com/igraph/igraph/compare/0.10.8..master +[0.10.8]: https://github.com/igraph/igraph/compare/0.10.7..0.10.8 [0.10.7]: https://github.com/igraph/igraph/compare/0.10.6..0.10.7 [0.10.6]: https://github.com/igraph/igraph/compare/0.10.5..0.10.6 [0.10.5]: https://github.com/igraph/igraph/compare/0.10.4..0.10.5 diff --git a/src/vendor/cigraph/CONTRIBUTORS.md b/src/vendor/cigraph/CONTRIBUTORS.md index 2e86e405fe5..fea623c89ba 100644 --- a/src/vendor/cigraph/CONTRIBUTORS.md +++ b/src/vendor/cigraph/CONTRIBUTORS.md @@ -78,6 +78,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Radoslav Fulek

💻
professorcode1

💻 + +
larah19

💻 + diff --git a/src/vendor/cigraph/CONTRIBUTORS.txt b/src/vendor/cigraph/CONTRIBUTORS.txt index a284efbef78..4174fce3b1c 100644 --- a/src/vendor/cigraph/CONTRIBUTORS.txt +++ b/src/vendor/cigraph/CONTRIBUTORS.txt @@ -56,6 +56,7 @@ flange-ipb (@flange-ipb) Juan Julián Merelo Guervós (@JJ) Radoslav Fulek (@rfulekjames) professorcode1 (@professorcode1) +larah19 (@larah19) This project follows the [all-contributors][1] specification. Contributions of any kind welcome! diff --git a/src/vendor/cigraph/appveyor.yml b/src/vendor/cigraph/appveyor.yml deleted file mode 100644 index d7d867a66d6..00000000000 --- a/src/vendor/cigraph/appveyor.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Ignore branches with names starting with certain keywords: -branches: - except: - - /^(github|travis)\/.+$/ - -# We always use a 64-bit machine, but can build x86 distributions -platform: - - x64 - -environment: - global: - VCPKG_DEFAULT_TRIPLET: x64-windows-static - - matrix: - - job_name: Static - - job_name: Dynamic - -cache: - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml - - C:\Tools\vcpkg\installed -> appveyor.yml - -install: - # Install dependencies for MSVC build - - choco install winflexbison - - # Choose VS 2015, https://www.appveyor.com/docs/lang/cpp/#visual-studio-2015 - - call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 - - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 - - # Update vcpkg, as included version does not have GMP - # https://www.appveyor.com/docs/lang/cpp/#vc-packaging-tool - - cd C:\Tools\vcpkg - # - git pull --quiet - # - .\bootstrap-vcpkg.bat -disableMetrics - # - vcpkg install yasm-tool:x86-windows - # - vcpkg install gmp - - vcpkg install libxml2 - - vcpkg integrate install - -for: - - matrix: - only: - - job_name: Static - before_build: - - cd "%APPVEYOR_BUILD_FOLDER%" - - mkdir build - - cd build - - cmake .. - -A x64 - -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake - -DVCPKG_TARGET_TRIPLET=x64-windows-static - -DIGRAPH_GRAPHML_SUPPORT=1 - -DIGRAPH_USE_INTERNAL_BLAS=1 -DIGRAPH_USE_INTERNAL_LAPACK=1 -DIGRAPH_USE_INTERNAL_ARPACK=1 -DIGRAPH_USE_INTERNAL_GLPK=1 -DIGRAPH_USE_INTERNAL_GMP=1 - -DIGRAPH_VERIFY_FINALLY_STACK=1 - - - matrix: - only: - - job_name: Dynamic - before_build: - - cd "%APPVEYOR_BUILD_FOLDER%" - - mkdir build - - cd build - - cmake .. - -A x64 - -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake - -DVCPKG_TARGET_TRIPLET=x64-windows-static - -DBUILD_SHARED_LIBS=1 - -DIGRAPH_GRAPHML_SUPPORT=1 - -DIGRAPH_USE_INTERNAL_BLAS=1 -DIGRAPH_USE_INTERNAL_LAPACK=1 -DIGRAPH_USE_INTERNAL_ARPACK=1 -DIGRAPH_USE_INTERNAL_GLPK=1 -DIGRAPH_USE_INTERNAL_GMP=1 - -DIGRAPH_VERIFY_FINALLY_STACK=1 - -configuration: Release - -build: - parallel: true - verbosity: minimal - -test_script: - - cd "%APPVEYOR_BUILD_FOLDER%" - - cd build - - ctest --output-on-failure -C Release - -on_failure: - - echo zipping everything after a failure... - - cd "%APPVEYOR_BUILD_FOLDER%" - - 7z a failed_state.zip . | grep -v "Compressing" - - appveyor PushArtifact failed_state.zip diff --git a/src/vendor/cigraph/include/igraph_attributes.h b/src/vendor/cigraph/include/igraph_attributes.h index 1cbc63dfe92..9773ce78df9 100644 --- a/src/vendor/cigraph/include/igraph_attributes.h +++ b/src/vendor/cigraph/include/igraph_attributes.h @@ -217,12 +217,19 @@ IGRAPH_EXPORT igraph_error_t igraph_attribute_combination_query(const igraph_att * \member init This function is called whenever a new graph object is * created, right after it is created but before any vertices or * edges are added. It is supposed to set the \c attr member of the \c - * igraph_t object. It is expected to return an error code. + * igraph_t object, which is guaranteed to be set to a null pointer + * before this function is called. It is expected to return an error code. * \member destroy This function is called whenever the graph object - * is destroyed, right before freeing the allocated memory. + * is destroyed, right before freeing the allocated memory. It is supposed + * to do any cleanup operations that are need to dispose of the \c attr + * member of the \c igraph_t object properly. The caller will set the + * \c attr member to a null pointer after this function returns. * \member copy This function is called when copying a graph with \ref * igraph_copy, after the structure of the graph has been already - * copied. It is expected to return an error code. + * copied. It is supposed to populate the \c attr member of the target + * \c igraph_t object. The \c attr member of the target is guaranteed to be + * set to a null pointer before this function is called. It is expected to + * return an error code. * \member add_vertices Called when vertices are added to a * graph, before adding the vertices themselves. * The number of vertices to add is supplied as an diff --git a/src/vendor/cigraph/include/igraph_mixing.h b/src/vendor/cigraph/include/igraph_mixing.h index 9b6953da75d..b69a6c8f777 100644 --- a/src/vendor/cigraph/include/igraph_mixing.h +++ b/src/vendor/cigraph/include/igraph_mixing.h @@ -50,11 +50,23 @@ IGRAPH_EXPORT igraph_error_t igraph_assortativity_degree(const igraph_t *graph, igraph_real_t *res, igraph_bool_t directed); -IGRAPH_EXPORT igraph_error_t igraph_joint_degree_matrix(const igraph_t *graph, - igraph_matrix_t *m, - igraph_integer_t dout, - igraph_integer_t din, - const igraph_vector_t *weights); +IGRAPH_EXPORT igraph_error_t igraph_joint_degree_matrix( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_matrix_t *jdm, + igraph_integer_t dout, igraph_integer_t din); + +IGRAPH_EXPORT igraph_error_t igraph_joint_degree_distribution( + const igraph_t *graph, const igraph_vector_t *weights, igraph_matrix_t *p, + igraph_neimode_t from_mode, igraph_neimode_t to_mode, + igraph_bool_t directed_neighbors, + igraph_bool_t normalized, + igraph_integer_t max_from_degree, igraph_integer_t max_to_degree); + +IGRAPH_EXPORT igraph_error_t igraph_joint_type_distribution( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_matrix_t *p, + const igraph_vector_int_t *from_types, const igraph_vector_int_t *to_types, + igraph_bool_t directed, igraph_bool_t normalized); __END_DECLS diff --git a/src/vendor/cigraph/include/igraph_structural.h b/src/vendor/cigraph/include/igraph_structural.h index 7f1907cf834..328a5807858 100644 --- a/src/vendor/cigraph/include/igraph_structural.h +++ b/src/vendor/cigraph/include/igraph_structural.h @@ -116,9 +116,11 @@ IGRAPH_EXPORT igraph_error_t igraph_avg_nearest_neighbor_degree(const igraph_t * igraph_vector_t *knn, igraph_vector_t *knnk, const igraph_vector_t *weights); -IGRAPH_EXPORT igraph_error_t igraph_degree_correlation_vector(const igraph_t *graph, igraph_vector_t *knnk, const igraph_vector_t *weights, - igraph_neimode_t from_mode, igraph_neimode_t to_mode, - igraph_bool_t directed_neighbors); +IGRAPH_EXPORT igraph_error_t igraph_degree_correlation_vector( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_vector_t *knnk, + igraph_neimode_t from_mode, igraph_neimode_t to_mode, + igraph_bool_t directed_neighbors); IGRAPH_EXPORT igraph_error_t igraph_feedback_arc_set(const igraph_t *graph, igraph_vector_int_t *result, const igraph_vector_t *weights, igraph_fas_algorithm_t algo); diff --git a/src/vendor/cigraph/interfaces/functions.yaml b/src/vendor/cigraph/interfaces/functions.yaml index 07df0cfd593..8d341ad4a1a 100644 --- a/src/vendor/cigraph/interfaces/functions.yaml +++ b/src/vendor/cigraph/interfaces/functions.yaml @@ -866,7 +866,7 @@ igraph_hub_score: PARAMS: |- GRAPH graph, OUT VERTEX_QTY vector, OUT REAL value, BOOLEAN scale=True, EDGEWEIGHTS weights=NULL, - INOUT ARPACKOPT options=arpack_defaults() + INOUT ARPACKOPT options=arpack_defaults DEPS: weights ON graph, vector ON graph igraph_authority_score: @@ -915,7 +915,8 @@ igraph_avg_nearest_neighbor_degree: igraph_degree_correlation_vector: PARAMS: |- - GRAPH graph, OUT VECTOR knnk, EDGEWEIGHTS weights=NULL, + GRAPH graph, EDGEWEIGHTS weights=NULL, + OUT VECTOR knnk, NEIMODE from_mode=OUT, NEIMODE to_mode=IN, BOOLEAN directed_neighbors=True DEPS: weights ON graph @@ -999,9 +1000,28 @@ igraph_assortativity_degree: igraph_joint_degree_matrix: PARAMS: |- - GRAPH graph, OUT MATRIX jdm, - INTEGER max_out_degree=-1, INTEGER max_in_degree=-1, - EDGEWEIGHTS weights=NULL + GRAPH graph, EDGEWEIGHTS weights=NULL, + OUT MATRIX jdm, + INTEGER max_out_degree=-1, INTEGER max_in_degree=-1 + DEPS: weights ON graph + +igraph_joint_degree_distribution: + PARAMS: |- + GRAPH graph, EDGEWEIGHTS weights=NULL, + OUT MATRIX p, + NEIMODE from_mode=OUT, NEIMODE to_mode=IN, + BOOLEAN directed_neighbors=True, + BOOLEAN normalized=True, + INTEGER max_from_degree=-1, INTEGER max_to_degree=-1 + DEPS: weights ON graph + +igraph_joint_type_distribution: + PARAMS: |- + GRAPH graph, EDGEWEIGHTS weights=NULL, + OUT MATRIX p, + INDEX_VECTOR from_types, INDEX_VECTOR to_types=NULL, + BOOLEAN directed=True, + BOOLEAN normalized=True DEPS: weights ON graph igraph_contract_vertices: diff --git a/src/vendor/cigraph/src/CMakeLists.txt b/src/vendor/cigraph/src/CMakeLists.txt index 8dd20f13052..4fd0ddb0244 100644 --- a/src/vendor/cigraph/src/CMakeLists.txt +++ b/src/vendor/cigraph/src/CMakeLists.txt @@ -324,7 +324,7 @@ add_library( add_dependencies(igraph parsersources) # Set soname for the library -set_target_properties(igraph PROPERTIES VERSION "3.1.2") +set_target_properties(igraph PROPERTIES VERSION "3.1.3") set_target_properties(igraph PROPERTIES SOVERSION 3) # Add extra compiler definitions if needed diff --git a/src/vendor/cigraph/src/centrality/centralization.c b/src/vendor/cigraph/src/centrality/centralization.c index 544dfca97a0..1f27ca1107d 100644 --- a/src/vendor/cigraph/src/centrality/centralization.c +++ b/src/vendor/cigraph/src/centrality/centralization.c @@ -77,11 +77,10 @@ igraph_real_t igraph_centralization(const igraph_vector_t *scores, igraph_bool_t normalized) { igraph_integer_t no_of_nodes = igraph_vector_size(scores); - igraph_real_t maxscore = 0.0; - igraph_real_t cent = 0.0; + igraph_real_t cent; if (no_of_nodes != 0) { - maxscore = igraph_vector_max(scores); + igraph_real_t maxscore = igraph_vector_max(scores); cent = no_of_nodes * maxscore - igraph_vector_sum(scores); if (normalized) { cent = cent / theoretical_max; diff --git a/src/vendor/cigraph/src/centrality/closeness.c b/src/vendor/cigraph/src/centrality/closeness.c index 681c0408d8b..1bb7d3b4a59 100644 --- a/src/vendor/cigraph/src/centrality/closeness.c +++ b/src/vendor/cigraph/src/centrality/closeness.c @@ -454,7 +454,7 @@ static igraph_error_t igraph_i_harmonic_centrality_unweighted(const igraph_t *gr igraph_real_t cutoff) { igraph_integer_t no_of_nodes = igraph_vcount(graph); - igraph_vector_t already_counted; + igraph_vector_int_t already_counted; igraph_vector_int_t *neis; igraph_integer_t i, j; igraph_adjlist_t allneis; @@ -476,7 +476,7 @@ static igraph_error_t igraph_i_harmonic_centrality_unweighted(const igraph_t *gr IGRAPH_ERROR("Invalid mode for harmonic centrality.", IGRAPH_EINVMODE); } - IGRAPH_VECTOR_INIT_FINALLY(&already_counted, no_of_nodes); + IGRAPH_VECTOR_INT_INIT_FINALLY(&already_counted, no_of_nodes); IGRAPH_DQUEUE_INT_INIT_FINALLY(&q, 100); IGRAPH_CHECK(igraph_adjlist_init(graph, &allneis, mode, IGRAPH_LOOPS, IGRAPH_MULTIPLE)); @@ -535,7 +535,7 @@ static igraph_error_t igraph_i_harmonic_centrality_unweighted(const igraph_t *gr /* Clean */ igraph_dqueue_int_destroy(&q); - igraph_vector_destroy(&already_counted); + igraph_vector_int_destroy(&already_counted); igraph_vit_destroy(&vit); igraph_adjlist_destroy(&allneis); IGRAPH_FINALLY_CLEAN(4); diff --git a/src/vendor/cigraph/src/centrality/coreness.c b/src/vendor/cigraph/src/centrality/coreness.c index 34b3fc42a6b..2d3a7089afd 100644 --- a/src/vendor/cigraph/src/centrality/coreness.c +++ b/src/vendor/cigraph/src/centrality/coreness.c @@ -1,8 +1,7 @@ /* -*- mode: C -*- */ /* IGraph library. - Copyright (C) 2006-2012 Gabor Csardi - 334 Harvard street, Cambridge, MA 02139 USA + Copyright (C) 2006-2023 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 @@ -15,10 +14,7 @@ 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 - + along with this program. If not, see . */ #include "igraph_community.h" @@ -29,7 +25,7 @@ /** * \function igraph_coreness - * \brief Finding the coreness of the vertices in a network. + * \brief The coreness of the vertices in a graph. * * The k-core of a graph is a maximal subgraph in which each vertex * has at least degree k. (Degree here means the degree in the @@ -63,81 +59,73 @@ igraph_error_t igraph_coreness(const igraph_t *graph, igraph_integer_t no_of_nodes = igraph_vcount(graph); igraph_integer_t *bin, *vert, *pos; igraph_integer_t maxdeg; - igraph_integer_t i, j = 0; igraph_vector_int_t neis; igraph_neimode_t omode; if (mode != IGRAPH_ALL && mode != IGRAPH_OUT && mode != IGRAPH_IN) { - IGRAPH_ERROR("Invalid mode in k-cores", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid mode in k-cores.", IGRAPH_EINVAL); } - if (!igraph_is_directed(graph) || mode == IGRAPH_ALL) { - mode = omode = IGRAPH_ALL; - } else if (mode == IGRAPH_IN) { - omode = IGRAPH_OUT; - } else { - omode = IGRAPH_IN; + if (!igraph_is_directed(graph)) { + mode = IGRAPH_ALL; } + omode = IGRAPH_REVERSE_MODE(mode); + /* catch null graph */ if (no_of_nodes == 0) { igraph_vector_int_clear(cores); return IGRAPH_SUCCESS; } vert = IGRAPH_CALLOC(no_of_nodes, igraph_integer_t); - if (vert == 0) { - IGRAPH_ERROR("Cannot calculate k-cores", IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ - } + IGRAPH_CHECK_OOM(vert, "Insufficient memory for k-cores."); IGRAPH_FINALLY(igraph_free, vert); + pos = IGRAPH_CALLOC(no_of_nodes, igraph_integer_t); - if (pos == 0) { - IGRAPH_ERROR("Cannot calculate k-cores", IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ - } + IGRAPH_CHECK_OOM(pos, "Insufficient memory for k-cores."); IGRAPH_FINALLY(igraph_free, pos); /* maximum degree + degree of vertices */ IGRAPH_CHECK(igraph_degree(graph, cores, igraph_vss_all(), mode, /* loops= */ true)); + /* null graph was already handled earlier, 'cores' is not empty */ maxdeg = igraph_vector_int_max(cores); bin = IGRAPH_CALLOC(maxdeg + 1, igraph_integer_t); - if (bin == 0) { - IGRAPH_ERROR("Cannot calculate k-cores", IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ - } + IGRAPH_CHECK_OOM(bin, "Insufficient memory for k-cores."); IGRAPH_FINALLY(igraph_free, bin); /* degree histogram */ - for (i = 0; i < no_of_nodes; i++) { - bin[VECTOR(*cores)[i] ] += 1; + for (igraph_integer_t i = 0; i < no_of_nodes; i++) { + bin[ VECTOR(*cores)[i] ] += 1; } /* start pointers */ - j = 0; - for (i = 0; i <= maxdeg; i++) { - igraph_integer_t k = bin[i]; - bin[i] = j; - j += k; + for (igraph_integer_t d = 0, start = 0; d <= maxdeg; d++) { + igraph_integer_t k = bin[d]; + bin[d] = start; + start += k; } /* sort in vert (and corrupt bin) */ - for (i = 0; i < no_of_nodes; i++) { + for (igraph_integer_t i = 0; i < no_of_nodes; i++) { pos[i] = bin[VECTOR(*cores)[i]]; vert[pos[i]] = i; bin[VECTOR(*cores)[i]] += 1; } /* correct bin */ - for (i = maxdeg; i > 0; i--) { - bin[i] = bin[i - 1]; + for (igraph_integer_t d = maxdeg; d > 0; d--) { + bin[d] = bin[d - 1]; } bin[0] = 0; /* this is the main algorithm */ IGRAPH_VECTOR_INT_INIT_FINALLY(&neis, maxdeg); - for (i = 0; i < no_of_nodes; i++) { + for (igraph_integer_t i = 0; i < no_of_nodes; i++) { igraph_integer_t v = vert[i]; IGRAPH_CHECK(igraph_neighbors(graph, &neis, v, omode)); igraph_integer_t nei_count = igraph_vector_int_size(&neis); - for (j = 0; j < nei_count; j++) { + for (igraph_integer_t j = 0; j < nei_count; j++) { igraph_integer_t u = VECTOR(neis)[j]; if (VECTOR(*cores)[u] > VECTOR(*cores)[v]) { igraph_integer_t du = VECTOR(*cores)[u]; diff --git a/src/vendor/cigraph/src/community/community_misc.c b/src/vendor/cigraph/src/community/community_misc.c index 9ec2e7d81a8..1f637043dfb 100644 --- a/src/vendor/cigraph/src/community/community_misc.c +++ b/src/vendor/cigraph/src/community/community_misc.c @@ -85,7 +85,7 @@ igraph_error_t igraph_community_to_membership(const igraph_matrix_int_t *merges, igraph_integer_t no_of_nodes = nodes; igraph_integer_t components = no_of_nodes - steps; igraph_integer_t i, found = 0; - igraph_vector_t tmp; + igraph_vector_int_t tmp; igraph_vector_bool_t already_merged; igraph_vector_int_t own_membership; igraph_bool_t using_own_membership = false; @@ -121,7 +121,7 @@ igraph_error_t igraph_community_to_membership(const igraph_matrix_int_t *merges, } IGRAPH_VECTOR_BOOL_INIT_FINALLY(&already_merged, steps + no_of_nodes); - IGRAPH_VECTOR_INIT_FINALLY(&tmp, steps); + IGRAPH_VECTOR_INT_INIT_FINALLY(&tmp, steps); for (i = steps - 1; i >= 0; i--) { igraph_integer_t c1 = MATRIX(*merges, i, 0); @@ -191,7 +191,7 @@ igraph_error_t igraph_community_to_membership(const igraph_matrix_int_t *merges, } } - igraph_vector_destroy(&tmp); + igraph_vector_int_destroy(&tmp); igraph_vector_bool_destroy(&already_merged); IGRAPH_FINALLY_CLEAN(2); @@ -249,11 +249,6 @@ igraph_error_t igraph_reindex_membership(igraph_vector_int_t *membership, for (i = 0; i < n; i++) { igraph_integer_t c = VECTOR(*membership)[i]; - if (c < 0) { - IGRAPH_ERRORF("Membership indices should non-negative. " - "Found member of cluster %" IGRAPH_PRId ".", IGRAPH_EINVAL, c); - } - if (c < 0) { IGRAPH_ERRORF("Membership indices should be non-negative. " "Found member of cluster %" IGRAPH_PRId ".", IGRAPH_EINVAL, c); @@ -566,7 +561,7 @@ static igraph_error_t igraph_i_entropy_and_mutual_information(const igraph_vecto igraph_integer_t i, n; igraph_integer_t k1; igraph_integer_t k2; - double *p1, *p2; + igraph_real_t *p1, *p2; igraph_sparsemat_t m; igraph_sparsemat_t mu; /* uncompressed */ igraph_sparsemat_iterator_t mit; @@ -580,12 +575,12 @@ static igraph_error_t igraph_i_entropy_and_mutual_information(const igraph_vecto } k1 = igraph_vector_int_max(v1) + 1; k2 = igraph_vector_int_max(v2) + 1; - p1 = IGRAPH_CALLOC(k1, double); + p1 = IGRAPH_CALLOC(k1, igraph_real_t); if (p1 == 0) { IGRAPH_ERROR("Insufficient memory for computing community entropy.", IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_free, p1); - p2 = IGRAPH_CALLOC(k2, double); + p2 = IGRAPH_CALLOC(k2, igraph_real_t); if (p2 == 0) { IGRAPH_ERROR("Insufficient memory for computing community entropy.", IGRAPH_ENOMEM); } @@ -833,8 +828,8 @@ static igraph_error_t igraph_i_compare_communities_rand( igraph_sparsemat_iterator_t mit; igraph_vector_t rowsums, colsums; igraph_integer_t i, nrow, ncol; - double rand, n; - double frac_pairs_in_1, frac_pairs_in_2; + igraph_real_t rand, n; + igraph_real_t frac_pairs_in_1, frac_pairs_in_2; if (igraph_vector_int_size(v1) <= 1) { IGRAPH_ERRORF("Rand indices not defined for only zero or one vertices. " @@ -878,7 +873,7 @@ static igraph_error_t igraph_i_compare_communities_rand( /* Calculate row and column sums */ nrow = igraph_sparsemat_nrow(&mu); ncol = igraph_sparsemat_ncol(&mu); - n = igraph_vector_int_size(v1) + 0.0; + n = igraph_vector_int_size(v1); IGRAPH_VECTOR_INIT_FINALLY(&rowsums, nrow); IGRAPH_VECTOR_INIT_FINALLY(&colsums, ncol); IGRAPH_CHECK(igraph_sparsemat_rowsums(&mu, &rowsums)); diff --git a/src/vendor/cigraph/src/community/edge_betweenness.c b/src/vendor/cigraph/src/community/edge_betweenness.c index a69bd9e77da..5ab37349ccb 100644 --- a/src/vendor/cigraph/src/community/edge_betweenness.c +++ b/src/vendor/cigraph/src/community/edge_betweenness.c @@ -39,11 +39,11 @@ static igraph_error_t igraph_i_rewrite_membership_vector(igraph_vector_int_t *membership) { const igraph_integer_t no = igraph_vector_int_max(membership) + 1; - igraph_vector_t idx; + igraph_vector_int_t idx; igraph_integer_t realno = 0; const igraph_integer_t len = igraph_vector_int_size(membership); - IGRAPH_VECTOR_INIT_FINALLY(&idx, no); + IGRAPH_VECTOR_INT_INIT_FINALLY(&idx, no); for (igraph_integer_t i = 0; i < len; i++) { const igraph_integer_t t = VECTOR(*membership)[i]; if (VECTOR(idx)[t]) { @@ -53,7 +53,7 @@ static igraph_error_t igraph_i_rewrite_membership_vector(igraph_vector_int_t *me VECTOR(*membership)[i] = VECTOR(idx)[t] - 1; } } - igraph_vector_destroy(&idx); + igraph_vector_int_destroy(&idx); IGRAPH_FINALLY_CLEAN(1); return IGRAPH_SUCCESS; diff --git a/src/vendor/cigraph/src/community/infomap/infomap.cc b/src/vendor/cigraph/src/community/infomap/infomap.cc index fe690948e17..91c9ed51402 100644 --- a/src/vendor/cigraph/src/community/infomap/infomap.cc +++ b/src/vendor/cigraph/src/community/infomap/infomap.cc @@ -151,25 +151,17 @@ static igraph_error_t infomap_partition(FlowGraph &fgraph, bool rcall) { oldCodeLength = greedy.codeLength; bool moved = true; - //igraph_integer_t count = 0; double inner_oldCodeLength = 1000; while (moved) { // main greedy optimizing loop inner_oldCodeLength = greedy.codeLength; moved = greedy.optimize(); - //count++; - if (fabs(greedy.codeLength - inner_oldCodeLength) < 1.0e-10) // if the move does'n reduce the codelenght -> exit ! { moved = false; } - - //if (count == 10) { - // greedy->tune(); - // count = 0; - //} } // transform the network to network of modules: @@ -320,7 +312,7 @@ igraph_error_t igraph_community_infomap(const igraph_t * graph, } } - *codelength = (igraph_real_t) shortestCodeLength / log(2.0); + *codelength = shortestCodeLength / log(2.0); IGRAPH_CHECK(igraph_reindex_membership(membership, NULL, NULL)); diff --git a/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.cc b/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.cc index 8b77d124e9c..405dc6a1da0 100644 --- a/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.cc +++ b/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.cc @@ -43,11 +43,7 @@ void FlowGraph::init(igraph_integer_t n, const igraph_vector_t *v_weights) { } FlowGraph::FlowGraph(igraph_integer_t n) { - init(n, NULL); -} - -FlowGraph::FlowGraph(igraph_integer_t n, const igraph_vector_t *v_weights) { - init(n, v_weights); + init(n, nullptr); } /* Build the graph from igraph_t object */ @@ -85,8 +81,8 @@ FlowGraph::FlowGraph(const igraph_t *graph, // We skip adding zero-weight edges. if (linkWeight > 0.0) { if (from != to) { - node[from].outLinks.push_back(make_pair(to, linkWeight)); - node[to].inLinks.push_back(make_pair(from, linkWeight)); + node[from].outLinks.emplace_back(to, linkWeight); + node[to].inLinks.emplace_back(from, linkWeight); } } } @@ -94,7 +90,7 @@ FlowGraph::FlowGraph(const igraph_t *graph, FlowGraph::FlowGraph(const FlowGraph &fgraph) { igraph_integer_t n = fgraph.Nnode; - init(n, NULL); + init(n, nullptr); for (igraph_integer_t i = 0; i < n; i++) { node[i] = fgraph.node[i]; } @@ -118,18 +114,17 @@ FlowGraph::FlowGraph(const FlowGraph &fgraph) { FlowGraph::FlowGraph(const FlowGraph &fgraph, const vector &sub_members) { igraph_integer_t sub_Nnode = sub_members.size(); - init(sub_Nnode, NULL); + init(sub_Nnode, nullptr); //XXX: use set of integer to ensure that elements are sorted set sub_mem(sub_members.begin(), sub_members.end()); - set::iterator it_mem = sub_mem.begin(); + auto it_mem = sub_mem.begin(); vector sub_renumber(fgraph.Nnode, -1); // id --> sub_id for (igraph_integer_t j = 0; j < sub_Nnode; j++) { - //int orig_nr = sub_members[j]; igraph_integer_t orig_nr = (*it_mem); node[j].teleportWeight = fgraph.node[orig_nr].teleportWeight; @@ -154,8 +149,8 @@ FlowGraph::FlowGraph(const FlowGraph &fgraph, const vector &su // printf("%2d | %4d to %4d\n", j, orig_nr, to); // printf("from %4d (%4d:%1.5f) to %4d (%4d)\n", j, orig_nr, // node[j].selfLink, to_newnr, to); - node[j].outLinks.push_back(make_pair(to_newnr, link_weight)); - node[to_newnr].inLinks.push_back(make_pair(j, link_weight)); + node[j].outLinks.emplace_back(to_newnr, link_weight); + node[to_newnr].inLinks.emplace_back(j, link_weight); } } } @@ -166,8 +161,8 @@ FlowGraph::FlowGraph(const FlowGraph &fgraph, const vector &su double link_weight = fgraph.node[orig_nr].inLinks[k].second; if (to < orig_nr) { if (sub_mem.find(to) != sub_mem.end()) { - node[j].inLinks.push_back(make_pair(to_newnr, link_weight)); - node[to_newnr].outLinks.push_back(make_pair(j, link_weight)); + node[j].inLinks.emplace_back(to_newnr, link_weight); + node[to_newnr].outLinks.emplace_back(j, link_weight); } } } @@ -180,7 +175,7 @@ FlowGraph::FlowGraph(const FlowGraph &fgraph, const vector &su the graph is "re" calibrate but NOT the given one. */ -void FlowGraph::swap(FlowGraph &fgraph) { +void FlowGraph::swap(FlowGraph &fgraph) noexcept { node.swap(fgraph.node); igraph_integer_t Nnode_tmp = fgraph.Nnode; @@ -345,14 +340,14 @@ void FlowGraph::eigenvector() { /* Compute the codeLength of the given network * note: (in **node, one node == one module) */ -void FlowGraph::calibrate() { +void FlowGraph::calibrate() noexcept { exit_log_exit = 0.0; exitFlow = 0.0; size_log_size = 0.0; for (igraph_integer_t i = 0; i < Nnode; i++) { // For each module // own node/module codebook - size_log_size += plogp(node[i].exit + node[i].size); + size_log_size += plogp(node[i].exit + node[i].size); // use of index codebook exitFlow += node[i].exit; diff --git a/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.h b/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.h index c4c866dee56..6364d5d0ce6 100644 --- a/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.h +++ b/src/vendor/cigraph/src/community/infomap/infomap_FlowGraph.h @@ -44,19 +44,19 @@ class FlowGraph { void init(igraph_integer_t n, const igraph_vector_t *nodeWeights); public: - FlowGraph(igraph_integer_t n); - FlowGraph(igraph_integer_t n, const igraph_vector_t *nodeWeights); + explicit FlowGraph(igraph_integer_t n); + FlowGraph(const FlowGraph &fgraph); FlowGraph(const FlowGraph &fgraph, const std::vector &sub_members); FlowGraph(const igraph_t *graph, const igraph_vector_t *e_weights, const igraph_vector_t *v_weights); - void swap(FlowGraph &fgraph); + void swap(FlowGraph &fgraph) noexcept; void initiate(); void eigenvector(); - void calibrate(); + void calibrate() noexcept; void back_to(const FlowGraph &fgraph); diff --git a/src/vendor/cigraph/src/community/infomap/infomap_Greedy.cc b/src/vendor/cigraph/src/community/infomap/infomap_Greedy.cc index 2714d2e3847..954e9169717 100644 --- a/src/vendor/cigraph/src/community/infomap/infomap_Greedy.cc +++ b/src/vendor/cigraph/src/community/infomap/infomap_Greedy.cc @@ -30,7 +30,7 @@ using namespace std; -Greedy::Greedy(FlowGraph * fgraph) : +Greedy::Greedy(FlowGraph *fgraph) : graph(fgraph), Nnode(graph->Nnode), alpha(graph->alpha), // teleportation probability @@ -38,8 +38,6 @@ Greedy::Greedy(FlowGraph * fgraph) : node_index(Nnode), - Nempty(0), - mod_empty(Nnode), mod_exit(Nnode), mod_size(Nnode), @@ -85,15 +83,14 @@ bool Greedy::optimize() { } for (igraph_integer_t i = 0; i < Nnode - 1; i++) { - //int randPos = i ; //XXX - igraph_integer_t randPos = static_cast(RNG_INTEGER(i, Nnode - 1)); + igraph_integer_t randPos = RNG_INTEGER(i, Nnode - 1); // swap i & randPos igraph_integer_t tmp = randomOrder[i]; randomOrder[i] = randomOrder[randPos]; randomOrder[randPos] = tmp; } - igraph_integer_t offset = 1; + igraph_uint_t offset = 1; vector redirect(Nnode, 0); vector > > flowNtoM(Nnode); @@ -201,8 +198,7 @@ bool Greedy::optimize() { // Randomize link order for optimized search for (igraph_integer_t j = 0; j < NmodLinks - 1; j++) { - //int randPos = j ; // XXX - igraph_integer_t randPos = static_cast(RNG_INTEGER(j, NmodLinks - 1)); + igraph_integer_t randPos = RNG_INTEGER(j, NmodLinks - 1); igraph_integer_t tmp_M = flowNtoM[j].first; double tmp_outFlow = flowNtoM[j].second.first; double tmp_inFlow = flowNtoM[j].second.second; @@ -315,7 +311,6 @@ bool Greedy::optimize() { /** Apply the move to the given network */ void Greedy::apply(bool sort) { -//void Greedy::level(Node ***node_tmp, bool sort) { //old fct prepare(sort) vector modSnode; // will give IDs of no-empty modules (nodes) @@ -332,9 +327,8 @@ void Greedy::apply(bool sort) { if (sort) { // sort by mod_size std::sort(modSnode.begin(), modSnode.end(), - [&](double a, double b) { return mod_size[a] > mod_size[b]; } ); + [&](size_t a, size_t b) { return mod_size[a] > mod_size[b]; } ); } - //modSnode[id_when_no_empty_node] = id_in_mod_tbl // Create the new graph FlowGraph tmp_fgraph(Nmod); @@ -346,7 +340,6 @@ void Greedy::apply(bool sort) { // creation of new nodes for (igraph_integer_t i = 0; i < Nmod; i++) { - //node_tmp[i] = new Node(); node_tmp[i].members.clear(); // clear membership node_tmp[i].exit = mod_exit[modSnode[i]]; node_tmp[i].size = mod_size[modSnode[i]]; @@ -355,7 +348,6 @@ void Greedy::apply(bool sort) { nodeInMod[modSnode[i]] = i; } - //nodeInMode[id_in_mod_tbl] = id_when_no_empty_node // Calculate outflow of links to different modules vector > outFlowNtoM(Nmod); @@ -381,7 +373,7 @@ void Greedy::apply(bool sort) { for (igraph_integer_t i = 0; i < Nmod; i++) { for (const auto &item : outFlowNtoM[i]) { if (item.first != i) { - node_tmp[i].outLinks.push_back(item); + node_tmp[i].outLinks.emplace_back(item); } } } @@ -406,7 +398,7 @@ void Greedy::apply(bool sort) { for (igraph_integer_t i = 0; i < Nmod; i++) { for (const auto &item : inFlowNtoM[i]) { if (item.first != i) { - node_tmp[i].inLinks.push_back(item); + node_tmp[i].inLinks.emplace_back(item); } } } @@ -436,67 +428,12 @@ void Greedy::apply(bool sort) { * - codeLength * according to **node / node[i]->index */ -/* unused */ -/* -void Greedy::tune(void) { - - exit_log_exit = 0.0; - size_log_size = 0.0; - exitFlow = 0.0; - - for (igraph_integer_t i = 0; i < Nnode; i++) { - mod_exit[i] = 0.0; - mod_size[i] = 0.0; - mod_danglingSize[i] = 0.0; - mod_teleportWeight[i] = 0.0; - mod_members[i] = 0; - } - - const std::vector &node = graph->node; - // Update all values except contribution from teleportation - for (igraph_integer_t i = 0; i < Nnode; i++) { - igraph_integer_t i_M = node_index[i]; // module id of node i - - mod_size[i_M] += node[i].size; - mod_danglingSize[i_M] += node[i].danglingSize; - mod_teleportWeight[i_M] += node[i].teleportWeight; - mod_members[i_M]++; - - for (const auto &link : node[i].outLinks) { - igraph_integer_t neighbor = link.first; - double neighbor_w = link.second; - igraph_integer_t neighbor_M = node_index[neighbor]; - if (i_M != neighbor_M) { // neighbor in an other module - mod_exit[i_M] += neighbor_w; - } - } - } - - // Update contribution from teleportation - for (igraph_integer_t i = 0; i < Nnode; i++) { - mod_exit[i] += (alpha * mod_size[i] + beta * mod_danglingSize[i]) * - (1.0 - mod_teleportWeight[i]); - } - - for (igraph_integer_t i = 0; i < Nnode; i++) { - exit_log_exit += plogp(mod_exit[i]); - size_log_size += plogp(mod_exit[i] + mod_size[i]); - exitFlow += mod_exit[i]; - } - exit = plogp(exitFlow); - - codeLength = exit - 2.0 * exit_log_exit + size_log_size - - nodeSize_log_nodeSize; -} -*/ /* Compute the new CodeSize if modules are merged as indicated by moveTo */ void Greedy::setMove(const std::vector &moveTo) { - //void Greedy::determMove(int *moveTo) { const std::vector &node = graph->node; - //printf("setMove nNode:%d \n", Nnode); for (igraph_integer_t i = 0 ; i < Nnode ; i++) { // pour chaque module igraph_integer_t oldM = i; igraph_integer_t newM = moveTo[i]; diff --git a/src/vendor/cigraph/src/community/infomap/infomap_Greedy.h b/src/vendor/cigraph/src/community/infomap/infomap_Greedy.h index 6c0594e33b9..87bf0b53cc9 100644 --- a/src/vendor/cigraph/src/community/infomap/infomap_Greedy.h +++ b/src/vendor/cigraph/src/community/infomap/infomap_Greedy.h @@ -34,19 +34,12 @@ class Greedy { public: - Greedy(FlowGraph * fgraph); + explicit Greedy(FlowGraph *fgraph); // initialise les attributs par rapport au graph void setMove(const std::vector &moveTo); - //virtual void determMove(int *moveTo); - bool optimize(); - //virtual void move(bool &moved); - void apply(bool sort); - //virtual void level(Node ***, bool sort); - - /* void tune(void); */ /* unused */ /**************************************************************************/ @@ -68,7 +61,7 @@ class Greedy { std::vector node_index; // module number of each node - igraph_integer_t Nempty; + igraph_integer_t Nempty = 0; std::vector mod_empty; std::vector mod_exit; // version tmp de node diff --git a/src/vendor/cigraph/src/community/infomap/infomap_Node.h b/src/vendor/cigraph/src/community/infomap/infomap_Node.h index ee3d128f85c..c3ef8c685ef 100644 --- a/src/vendor/cigraph/src/community/infomap/infomap_Node.h +++ b/src/vendor/cigraph/src/community/infomap/infomap_Node.h @@ -31,21 +31,22 @@ struct Node { - Node() : selfLink(0.0), exit(0.0), size(0.0) {} - Node(igraph_integer_t modulenr, double tpweight) : Node() { - teleportWeight = tpweight; + Node() = default; + Node(igraph_integer_t modulenr, double tpweight) : + teleportWeight(tpweight) + { members.push_back(modulenr); // members = [nodenr] } std::vector members; std::vector< std::pair > inLinks; std::vector< std::pair > outLinks; - double selfLink; + double selfLink = 0.0; - double teleportWeight; - double danglingSize; - double exit; - double size; + double teleportWeight = 0.0; + double danglingSize = 0.0; + double exit = 0.0; + double size = 0.0; }; #endif // INFOMAP_NODE_H diff --git a/src/vendor/cigraph/src/community/label_propagation.c b/src/vendor/cigraph/src/community/label_propagation.c index 0b92185bd59..09a9eb743a7 100644 --- a/src/vendor/cigraph/src/community/label_propagation.c +++ b/src/vendor/cigraph/src/community/label_propagation.c @@ -2,7 +2,7 @@ /* vim:set ts=4 sw=4 sts=4 et: */ /* IGraph library. - Copyright (C) 2007-2020 The igraph development team + Copyright (C) 2007-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 @@ -15,10 +15,7 @@ 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 - + along with this program. If not, see . */ #include "igraph_community.h" @@ -133,7 +130,7 @@ igraph_error_t igraph_community_label_propagation(const igraph_t *graph, igraph_bool_t unlabelled_left; igraph_neimode_t reversed_mode; - igraph_vector_t label_counters; + igraph_vector_t label_counters; /* real type, stores weight sums */ igraph_vector_int_t dominant_labels, nonzero_labels, node_order; /* We make a copy of 'fixed' as a pointer into 'fixed_copy' after casting diff --git a/src/vendor/cigraph/src/community/spinglass/NetDataTypes.cpp b/src/vendor/cigraph/src/community/spinglass/NetDataTypes.cpp index 3156d35126a..fecfacd670f 100644 --- a/src/vendor/cigraph/src/community/spinglass/NetDataTypes.cpp +++ b/src/vendor/cigraph/src/community/spinglass/NetDataTypes.cpp @@ -42,53 +42,6 @@ ***************************************************************************/ #include "NetDataTypes.h" -#include - -//################################################################################# -//############################################################################### -//Constructor -NNode::NNode(unsigned long ind, unsigned long c_ind, DLList *ll, const char *n, int states) { - index = ind; - cluster_index = c_ind; - neighbours = new DLList(); - n_links = new DLList(); - global_link_list = ll; - strcpy(name, n); - color.red = 0; - color.green = 0; - color.blue = 0; - strcpy(color.pajek_c, "Green"); - clustering = 0.0; - marker = 0; - affiliations = 0; - weight = 0.0; - affinity = 0.0; - distance = 0; - max_states = states; - state_history = new unsigned long[states + 1]; -} - -//Destructor -NNode::~NNode() { - Disconnect_From_All(); - delete neighbours; - delete n_links; - delete [] state_history; - neighbours = NULL; - n_links = NULL; - state_history = NULL; -} - -void NNode::Add_StateHistory(unsigned int state) { - if (max_states >= state) { - state_history[state]++; - } -} - -void NNode::Set_Color(RGBcolor c) { - color.red = c.red; color.blue = c.blue; color.green = c.green; - strcpy(color.pajek_c, c.pajek_c); -} int NNode::Connect_To(NNode* neighbour, double weight_) { NLink *link; @@ -96,26 +49,26 @@ int NNode::Connect_To(NNode* neighbour, double weight_) { if (!neighbour) { return 0; } - if (!(neighbours->Is_In_List(neighbour)) && (neighbour != this)) { - neighbours->Push(neighbour); // nachbar hier eintragen - neighbour->neighbours->Push(this); // diesen knoten beim nachbarn eintragen + if (!(neighbours.Is_In_List(neighbour)) && (neighbour != this)) { + neighbours.Push(neighbour); // nachbar hier eintragen + neighbour->neighbours.Push(this); // diesen knoten beim nachbarn eintragen link = new NLink(this, neighbour, weight_); //link erzeugen global_link_list->Push(link); // in globaler liste eintragen - n_links->Push(link); // bei diesem Knoten eintragen - neighbour->n_links->Push(link); // beim nachbarn eintragen + n_links.Push(link); // bei diesem Knoten eintragen + neighbour->n_links.Push(link); // beim nachbarn eintragen - return (1); + return 1; } - return (0); + return 0; } -NLink *NNode::Get_LinkToNeighbour(NNode* neighbour) { +NLink *NNode::Get_LinkToNeighbour(const NNode* neighbour) { DLList_Iter iter; - NLink *l_cur, *link = NULL; + NLink *l_cur, *link = nullptr; bool found = false; // finde einen bestimmten Link aus der Liste der links eines Knotens - l_cur = iter.First(n_links); + l_cur = iter.First(&n_links); while (!iter.End() && !found) { if (((l_cur->Get_Start() == this) && (l_cur->Get_End() == neighbour)) || ((l_cur->Get_End() == this) && (l_cur->Get_Start() == neighbour))) { found = true; @@ -126,93 +79,24 @@ NLink *NNode::Get_LinkToNeighbour(NNode* neighbour) { if (found) { return link; } else { - return NULL; + return nullptr; } } -int NNode::Disconnect_From(NNode* neighbour) { +igraph_integer_t NNode::Disconnect_From(NNode* neighbour) { //sollen doppelte Links erlaubt sein?? s.o. - if (!neighbours) { - return 0; - } - neighbours->fDelete(neighbour); - n_links->fDelete(Get_LinkToNeighbour(neighbour)); - neighbour->n_links->fDelete(neighbour->Get_LinkToNeighbour(this)); - neighbour->neighbours->fDelete(this); + neighbours.fDelete(neighbour); + n_links.fDelete(Get_LinkToNeighbour(neighbour)); + neighbour->n_links.fDelete(neighbour->Get_LinkToNeighbour(this)); + neighbour->neighbours.fDelete(this); return 1; } -int NNode::Disconnect_From_All() { - int number_of_neighbours = 0; - while (neighbours->Size()) { - Disconnect_From(neighbours->Pop()); +igraph_integer_t NNode::Disconnect_From_All() { + igraph_integer_t number_of_neighbours = 0; + while (neighbours.Size()) { + Disconnect_From(neighbours.Pop()); number_of_neighbours++; } - return (number_of_neighbours) ; -} - -/* -int NNode::Disconnect_From_All_Grandchildren() -{ - int n_l=links->Size(); - unsigned long pos=0; - while ((n_l--)>1) { //alle bis auf das erste loeschen - pos=(links->Get(n_l+1))->links->Is_In_List(this); - // printf("%d %d\n",n_l,pos); - (links->Get(n_l+1))->links->Delete(pos); - } - return(pos) ; -} -*/ - -double NNode::Get_Links_Among_Neigbours() { -// long neighbours1, neighbours2; - double lam = 0; - DLList_Iter iter1, iter2; -// neighbours1=neighbours->Size(); //so viele Nachbarn hat die Betrachtete Node - NNode *step1, *step2; - step1 = iter1.First(neighbours); - while (!iter1.End()) { // for (int n1=1;n1<=neighbours1; n1++) - //step1=neighbours->Get(n1); - //neighbours2=step1->neighbours->Size(); //so viele Nachbarn hat der n1-ste Nachbar - step2 = iter2.First(step1->Get_Neighbours()); - while (!iter2.End()) { //for (int n2=1;n2<=neighbours2; n2++) - //step2=step1->neighbours->Get(n2); - if (step2->Get_Neighbours()->Is_In_List(this)) { - lam++; - } - step2 = iter2.Next(); - } - step1 = iter1.Next(); - } - return (lam / 2.0); -} - - -double NNode::Get_Clustering() { - double c; - unsigned long k; - k = neighbours->Size(); - if (k <= 1) { - return (0); - } - c = 2.0 * Get_Links_Among_Neigbours() / double(k * k - k); - return (c); -} -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//Constructor -NLink::NLink(NNode *s, NNode *e, double w) { - start = s; - end = e; - weight = w; - old_weight = 0; - marker = 0; -} - -//Destructor -NLink::~NLink() { - if (start && end) { - start->Disconnect_From(end); - } + return number_of_neighbours ; } diff --git a/src/vendor/cigraph/src/community/spinglass/NetDataTypes.h b/src/vendor/cigraph/src/community/spinglass/NetDataTypes.h index a36cafd6c97..648cd2010f3 100644 --- a/src/vendor/cigraph/src/community/spinglass/NetDataTypes.h +++ b/src/vendor/cigraph/src/community/spinglass/NetDataTypes.h @@ -43,38 +43,47 @@ #ifndef NETDATATYPES_H #define NETDATATYPES_H +#include "igraph_types.h" + +#include #include +// In igraph, we set node names to be a string representation of the one-based +// vertex ID. This takes at most 20 characters. Add one for a potential sign +// (should not happen) and one more for the null terminator. +#define SPINGLASS_MAX_NAME_LEN 22 + //########################################################################################### struct HUGE_INDEX { unsigned int field_index; - unsigned long in_field_index; + igraph_integer_t in_field_index; }; -template class HugeArray { -private: - unsigned long int size; - unsigned int highest_field_index; - unsigned long max_bit_left; - unsigned long max_index; +template +class HugeArray { + igraph_integer_t size = 2; + unsigned int highest_field_index = 0; + const igraph_integer_t max_bit_left = 1UL << 31; //wir setzen das 31. Bit auf 1 + igraph_integer_t max_index = 0; DATA *data; DATA *fields[32]; public: - HUGE_INDEX get_huge_index(unsigned long); - DATA &Set(unsigned long); - DATA Get(unsigned long); HugeArray(); + HugeArray(const HugeArray &) = delete; + HugeArray & operator = (const HugeArray &) = delete; ~HugeArray(); - DATA &operator[](unsigned long); - unsigned long Size() { - return max_index; - } + HUGE_INDEX get_huge_index(igraph_integer_t) const; + DATA &Set(igraph_integer_t index); + DATA Get(igraph_integer_t index) { return Set(index); } + DATA &operator[](igraph_integer_t index) { return Set(index); } + igraph_integer_t Size() const { return max_index; } } ; + //############################################################################################### template class DLList; template class DL_Indexed_List; -template class ClusterList; +template using ClusterList= DLList; template class DLList_Iter; template @@ -82,14 +91,13 @@ class DLItem { friend class DLList ; friend class DL_Indexed_List; friend class DLList_Iter; -private: + L_DATA item; - unsigned long index; + igraph_integer_t index; DLItem *previous; DLItem *next; - DLItem(L_DATA i, unsigned long ind); - DLItem(L_DATA i, unsigned long ind, DLItem *p, DLItem *n); - ~DLItem(); + DLItem(L_DATA i, igraph_integer_t ind); + DLItem(L_DATA i, igraph_integer_t ind, DLItem *p, DLItem *n); public: void del() { delete item; @@ -100,389 +108,185 @@ template class DLList { friend class DLList_Iter; protected: - DLItem *head; - DLItem *tail; - unsigned long number_of_items; - DLItem *pInsert(L_DATA, DLItem*); - L_DATA pDelete(DLItem*); + DLItem *head; + DLItem *tail; + igraph_integer_t number_of_items = 0; + virtual DLItem *pInsert(L_DATA, DLItem*); + virtual L_DATA pDelete(DLItem*); public: DLList(); - ~DLList(); - unsigned long Size() { + DLList(const DLList &) = delete; + DLList & operator = (const DLList &) = delete; + virtual ~DLList(); + igraph_integer_t Size() const { return number_of_items; } - int Insert(L_DATA, unsigned long); - int Delete(unsigned long); int fDelete(L_DATA); - L_DATA Push(L_DATA); - L_DATA Pop(); - L_DATA Get(unsigned long); - int Enqueue(L_DATA); - L_DATA Dequeue(); - unsigned long Is_In_List(L_DATA); + virtual L_DATA Push(L_DATA); + virtual L_DATA Pop(); + virtual L_DATA Get(igraph_integer_t); + igraph_integer_t Is_In_List(L_DATA); void delete_items(); }; template -class DL_Indexed_List : virtual public DLList { - friend class DLList_Iter; -private: - DLItem *pInsert(L_DATA, DLItem*); - L_DATA pDelete(DLItem*); +class DL_Indexed_List : public DLList { + DLItem *pInsert(L_DATA, DLItem*) final; + L_DATA pDelete(DLItem*) final; HugeArray*> array; - unsigned long last_index; + igraph_integer_t last_index = 0; + public: - DL_Indexed_List(); - ~DL_Indexed_List(); - L_DATA Push(L_DATA); - L_DATA Pop(); - L_DATA Get(unsigned long); + DL_Indexed_List() = default; + L_DATA Push(L_DATA) final; + L_DATA Pop() final; + L_DATA Get(igraph_integer_t) final; }; //##################################################################################################### template class DLList_Iter { -private: - DLList *list; - DLItem *current; - bool end_reached; + const DLList *list = nullptr; + const DLItem *current = nullptr; + bool end_reached = true; + public: - DLList_Iter(); - ~DLList_Iter() { - end_reached = true; - }; L_DATA Next(); L_DATA Previous(); - L_DATA First(DLList *l); - L_DATA Last(DLList *l); - bool End() { + L_DATA First(const DLList *l); + L_DATA Last(const DLList *l); + bool End() const { return end_reached; } - DLItem *Get_Current() { - return current; - } - L_DATA Get_Current_Item() { - return current->item; - } - void Set_Current(DLItem *c) { - current = c; - } - void Set_Status(bool s) { - end_reached = s; - } bool Swap(DLList_Iter); //swapt die beiden Elemente, wenn sie in der gleichen Liste stehen!! - }; //##################################################################################################### -struct RGBcolor { - unsigned int red; - unsigned int green; - unsigned int blue; - char pajek_c[20]; -}; -//------------------------------------------------------------------------------- class NLink; class NNode { - friend class NLink; -private : - unsigned long index; - unsigned long cluster_index; - unsigned long marker, affiliations; - unsigned long *state_history; - unsigned int max_states; - long distance; - double clustering; - double weight; - double affinity; -// double old_weight; + igraph_integer_t index; + igraph_integer_t cluster_index; + igraph_integer_t marker = 0; + double weight = 0.0; - DLList *neighbours; //list with pointers to neighbours - DLList *n_links; + DLList neighbours; //list with pointers to neighbours + DLList n_links; DLList *global_link_list; - char name[255]; - RGBcolor color; + char name[SPINGLASS_MAX_NAME_LEN]; public : - NNode(unsigned long, unsigned long, DLList*, const char*, int); - ~NNode(); - unsigned long Get_Index() { - return (index); + NNode(igraph_integer_t ind, igraph_integer_t c_ind, DLList *ll, const char *n) : + index(ind), cluster_index(c_ind), global_link_list(ll) + { + strcpy(name, n); + } + NNode(const NNode &) = delete; + NNode &operator=(const NNode &) = delete; + ~NNode() { Disconnect_From_All(); } + + igraph_integer_t Get_Index() const { + return index; } - unsigned long Get_ClusterIndex() { - return (cluster_index); + igraph_integer_t Get_ClusterIndex() const { + return cluster_index; } - unsigned long Get_Marker() { + igraph_integer_t Get_Marker() const { return marker; } - void Set_Marker(unsigned long m) { + void Set_Marker(igraph_integer_t m) { marker = m; } - unsigned long Get_Affiliations() { - return affiliations; - } - void Set_Affiliations(unsigned long m) { - affiliations = m; - } - void Set_ClusterIndex(unsigned long ci) { + void Set_ClusterIndex(igraph_integer_t ci) { cluster_index = ci; } - void Set_Index(unsigned long i) { - index = i; - } - unsigned long Get_Degree() { - return (neighbours->Size()); + igraph_integer_t Get_Degree() const { + return (neighbours.Size()); } - char *Get_Name() { + const char *Get_Name() { return name; } - void Set_Name(char* n) { + void Set_Name(const char *n) { strcpy(name, n); } - double Get_Links_Among_Neigbours(); - double Get_Clustering(); - double Get_Weight() { + double Get_Weight() const { return weight; } - double Get_Affinity() { - return affinity; - } - unsigned long *Get_StateHistory() { - return state_history; - } - void Add_StateHistory(unsigned int q); - // double Get_OldWeight() {return old_weight;} void Set_Weight(double w) { weight = w; } - void Set_Affinity(double w) { - affinity = w; + int Connect_To(NNode*, double); + const DLList *Get_Neighbours() const { + return &neighbours; } - - // void Set_OldWeight(double w) {old_weight=w;} - long Get_Distance() { - return distance; + const DLList *Get_Links() const { + return &n_links; } - void Set_Distance(long d) { - distance = d; - } - int Connect_To(NNode*, double); - DLList *Get_Neighbours() { - return neighbours; - } - DLList *Get_Links() { - return n_links; - } - int Disconnect_From(NNode*); - int Disconnect_From_All(); - bool Is_Linked_To(NNode*); - RGBcolor Get_Color() { - return color; - } - void Set_Color(RGBcolor c); - NLink *Get_LinkToNeighbour(NNode *neighbour); + igraph_integer_t Disconnect_From(NNode*); + igraph_integer_t Disconnect_From_All(); + NLink *Get_LinkToNeighbour(const NNode *neighbour); }; //##################################################################################################### class NLink { - friend class NNode; -private : + NNode *start; NNode *end; double weight; - double old_weight; - unsigned long index; - unsigned long marker; + public : - NLink( NNode*, NNode*, double); - ~NLink(); - unsigned long Get_Start_Index() { - return (start->Get_Index()); - } - unsigned long Get_End_Index() { - return (end->Get_Index()); - } - NNode *Get_Start() { - return (start); - } - NNode *Get_End() { - return (end); - } - double Get_Weight() { - return weight; - } - void Set_Weight(double w) { - weight = w; - } - double Get_OldWeight() { - return old_weight; - } - void Set_OldWeight(double w) { - old_weight = w; - } - unsigned long Get_Marker() { - return marker; - } - void Set_Marker(unsigned long m) { - marker = m; - } - unsigned long Get_Index() { - return index; - } - void Set_Index(unsigned long i) { - index = i; - } -}; + NLink(NNode *s, NNode *e, double w) : start(s), end(e), weight(w) { } + NLink(const NLink &) = delete; + NLink & operator = (const NLink &) = delete; + ~NLink() { start->Disconnect_From(end); } -//##################################################################################################### + NNode *Get_Start() { return start; } + NNode *Get_End() { return end; } + const NNode *Get_Start() const { return start; } + const NNode *Get_End() const { return end; } -template class ClusterList : public DLList { - friend class DLList_Iter; -private: - long links_out_of_cluster; - unsigned long links_inside_cluster; - unsigned long frequency; - double cluster_energy; - DLList *candidates; - long marker; -public: - ClusterList(); - ~ClusterList(); - long Get_Links_OOC() { - return (links_out_of_cluster); - } - void Set_Links_OOC(long looc) { - links_out_of_cluster = looc; - } - unsigned long Get_Links_IC() { - return (links_inside_cluster); - } - unsigned long Get_Frequency() { - return (frequency); - } - void IncreaseFrequency() { - frequency++; - } - void Set_Links_IC(unsigned long lic) { - links_inside_cluster = lic; - } - double Get_Energy() { - return (cluster_energy); - } - void Set_Energy(double e) { - cluster_energy = e; - } - DLList *Get_Candidates() { - return candidates; - } - bool operator<(ClusterList &b); - bool operator==(ClusterList &b); - long Get_Marker() { - return marker; - } - void Set_Marker(long m) { - marker = m; - } + double Get_Weight() const { return weight; } }; -//##################################################################################################### -template -class DL_Node_List : virtual public DL_Indexed_List { - friend class DLList_Iter; -private: - DLItem *pInsert(NNode*, DLItem*); - NNode* pDelete(DLItem*); - HugeArray*> array; - unsigned long last_index; -public: - DL_Node_List(); - ~DL_Node_List(); - NNode* Push(NNode*); - NNode* Pop(); - NNode* Get(unsigned long); - int Delete(unsigned long); -}; //##################################################################################################### - - -struct cluster_join_move { - ClusterList *c1; - ClusterList *c2; - double joint_energy; - long joint_looc; - unsigned long joint_lic; -} ; - struct network { - DL_Indexed_List *node_list; - DL_Indexed_List *link_list; - DL_Indexed_List*> *cluster_list; - // DL_Indexed_List *moveset; - unsigned long max_k; - unsigned long min_k; - unsigned long diameter; - double av_weight; - double max_weight; - double min_weight; + DL_Indexed_List node_list; + DL_Indexed_List link_list; + DL_Indexed_List*> cluster_list; double sum_weights; - double av_k; - double av_bids; - unsigned long max_bids; - unsigned long min_bids; - unsigned long sum_bids; - network() { - node_list = new DL_Indexed_List(); - link_list = new DL_Indexed_List(); - cluster_list = new DL_Indexed_List*>(); - } + network() = default; + network (const network &) = delete; + network & operator = (const network &) = delete; ~network() { ClusterList *cl_cur; - while (link_list->Size()) { - delete link_list->Pop(); + while (link_list.Size()) { + delete link_list.Pop(); } - while (node_list->Size()) { - delete node_list->Pop(); + while (node_list.Size()) { + delete node_list.Pop(); } - while (cluster_list->Size()) { - cl_cur = cluster_list->Pop(); + while (cluster_list.Size()) { + cl_cur = cluster_list.Pop(); while (cl_cur->Size()) { cl_cur->Pop(); } delete cl_cur; } - delete link_list; - delete node_list; - delete cluster_list; } }; -/* -struct network -{ - DLList *node_list; - DLList *link_list; - DLList*> *cluster_list; - DLList *moveset; -} ; -*/ - template HugeArray::HugeArray() { - max_bit_left = 1UL << 31; //wir setzen das 31. Bit auf 1 - size = 2; - max_index = 0; - highest_field_index = 0; data = new DATA[2]; //ein extra Platz fuer das Nullelement data[0] = 0; data[1] = 0; - for (int i = 0; i < 32; i++) { - fields[i] = NULL; + for (auto & field : fields) { + field = nullptr; } fields[highest_field_index] = data; } @@ -495,10 +299,10 @@ template HugeArray::~HugeArray() { } template -HUGE_INDEX HugeArray::get_huge_index(unsigned long index) { +HUGE_INDEX HugeArray::get_huge_index(igraph_integer_t index) const { HUGE_INDEX h_index; unsigned int shift_index = 0; - unsigned long help_index; + igraph_integer_t help_index; help_index = index; if (index < 2) { h_index.field_index = 0; @@ -511,83 +315,50 @@ HUGE_INDEX HugeArray::get_huge_index(unsigned long index) { shift_index++; } h_index.field_index = 31 - shift_index; // das hoechste besetzte Bit im Index - help_index = 1UL << h_index.field_index; // in help_index wird das hoechste besetzte Bit von Index gesetzt + help_index = igraph_integer_t(1) << h_index.field_index; // in help_index wird das hoechste besetzte Bit von Index gesetzt h_index.in_field_index = (index ^ help_index); // index XOR help_index, womit alle bits unter dem hoechsten erhalten bleiben return h_index; } template -DATA &HugeArray::Set(unsigned long int index) { - HUGE_INDEX h_index; - unsigned long data_size; +DATA &HugeArray::Set(igraph_integer_t index) { + igraph_integer_t data_size; while (size < index + 1) { highest_field_index++; data_size = 1UL << highest_field_index; data = new DATA[data_size]; - for (unsigned long i = 0; i < data_size; i++) { + for (igraph_integer_t i = 0; i < data_size; i++) { data[i] = 0; } size = size + data_size; //overflow noch abfangen - //printf("Vergroesserung auf: %u bei index %u\n",size,index); fields[highest_field_index] = data; } - h_index = get_huge_index(index); -//printf("index %lu = %lu . %lu\n",index,h_index.field_index,h_index.in_field_index); + HUGE_INDEX h_index = get_huge_index(index); data = fields[h_index.field_index]; if (max_index < index) { max_index = index; } - return (data[h_index.in_field_index]); -} - -template -DATA HugeArray::Get(unsigned long index) { - return (Set(index)); -} - - -template -DATA &HugeArray::operator[](unsigned long index) { - return (Set(index)); + return data[h_index.in_field_index]; } //############################################################################### template -DLItem::DLItem(L_DATA i, unsigned long ind) : item(i), index(ind), previous(0), next(0) { -} +DLItem::DLItem(L_DATA i, igraph_integer_t ind) : + item(i), index(ind), previous(nullptr), next(nullptr) { } template -DLItem::DLItem(L_DATA i, unsigned long ind, DLItem *p, DLItem *n) : item(i), index(ind), previous(p), next(n) { -} - -template -DLItem::~DLItem() { -//delete item; //eigentlich muessten wir pruefen, ob item ueberhaupt ein Pointer ist... -//previous=NULL; -//next=NULL; -} - +DLItem::DLItem(L_DATA i, igraph_integer_t ind, DLItem *p, DLItem *n) : + item(i), index(ind), previous(p), next(n) { } //###################################################################################################################### template DLList::DLList() { - head = tail = NULL; - number_of_items = 0; head = new DLItem(NULL, 0); //fuer head und Tail gibt es das gleiche Array-Element!! Vorsicht!! tail = new DLItem(NULL, 0); - if ( !head || !tail ) { - if (head) { - delete (head); - } - if (tail) { - delete (tail); - } - return; - } else { - head->next = tail; - tail->previous = head; - } + + head->next = tail; + tail->previous = head; } template @@ -595,11 +366,10 @@ DLList::~DLList() { DLItem *cur = head, *next; while (cur) { next = cur->next; - delete (cur); + delete cur; cur = next; } number_of_items = 0; - // printf("Liste Zerstoert!\n"); } template @@ -617,57 +387,29 @@ void DLList::delete_items() { //privates Insert template DLItem *DLList::pInsert(L_DATA data, DLItem *pos) { - DLItem *i = new DLItem(data, number_of_items + 1, pos->previous, pos); - if (i) { - pos->previous->next = i; - pos->previous = i; - number_of_items++; - return (i); - } else { - return (0); - } + auto *i = new DLItem(data, number_of_items + 1, pos->previous, pos); + pos->previous->next = i; + pos->previous = i; + number_of_items++; + return i; } //privates delete template L_DATA DLList::pDelete(DLItem *i) { + assert(number_of_items > 0); L_DATA data = i->item; i->previous->next = i->next; i->next->previous = i->previous; -// array[i->index]=0; - delete (i); + delete i; number_of_items--; - return (data); -} -//oeffentliches Insert -template -int DLList::Insert(L_DATA data, unsigned long pos) { - if ((pos < 0) || (pos > (number_of_items))) { - return (0); - } - DLItem *cur = head; - while (pos--) { - cur = cur->next; - } - return (pInsert(data, cur) != 0); -} -//oeffentliche Delete -template -int DLList::Delete(unsigned long pos) { - if ((pos < 0) || (pos > (number_of_items))) { - return (0); - } - DLItem *cur = head; - while (pos--) { - cur = cur->next; - } - return (pDelete(cur) != 0); + return data; } //oeffentliche Delete template int DLList::fDelete(L_DATA data) { if ((number_of_items == 0) || (!data)) { - return (0); + return 0; } DLItem *cur; cur = head->next; @@ -677,31 +419,26 @@ int DLList::fDelete(L_DATA data) { if (cur != tail) { return (pDelete(cur) != 0); } - return (0); + return 0; } template L_DATA DLList::Push(L_DATA data) { - DLItem *tmp; - tmp = pInsert(data, tail); - if (tmp) { - return (tmp->item); - } - return (0); + DLItem *tmp = pInsert(data, tail); + return tmp->item; } template L_DATA DLList::Pop() { - return (pDelete(tail->previous)); + return pDelete(tail->previous); } template -L_DATA DLList::Get(unsigned long pos) { +L_DATA DLList::Get(igraph_integer_t pos) { if ((pos < 1) || (pos > (number_of_items + 1))) { - return (0); + return 0; } -// return(array[pos]->item); DLItem *cur = head; while (pos--) { cur = cur->next; @@ -709,188 +446,69 @@ L_DATA DLList::Get(unsigned long pos) { return (cur->item); } - -template -int DLList::Enqueue(L_DATA data) { - return (pInsert(data, tail) != 0); -} - -template -L_DATA DLList::Dequeue() { - return (pDelete(head->next)); -} - //gibt Index des gesuchte Listenelement zurueck, besser waere eigentlich zeiger template -unsigned long DLList::Is_In_List(L_DATA data) { +igraph_integer_t DLList::Is_In_List(L_DATA data) { DLItem *cur = head, *next; - unsigned long pos = 0; + igraph_integer_t pos = 0; while (cur) { next = cur->next; if (cur->item == data) { - return (pos) ; + return pos ; } cur = next; pos++; } - return (0); + return 0; } //###################################################################################################################### -template -DL_Indexed_List::DL_Indexed_List() : DLList() { - last_index = 0; -} - -template -DL_Indexed_List::~DL_Indexed_List() { - /* This is already done by the DLList destructor */ - /* DLItem *cur, *next; */ - /* cur=this->head; */ - /* while (cur) */ - /* { */ - /* next=cur->next; */ - /* delete(cur); */ - /* cur=next; */ - /* } */ - /* this->number_of_items=0; */ - // printf("Liste Zerstoert!\n"); -} //privates Insert template DLItem *DL_Indexed_List::pInsert(L_DATA data, DLItem *pos) { - DLItem *i = new DLItem(data, last_index, pos->previous, pos); - if (i) { - pos->previous->next = i; - pos->previous = i; - this->number_of_items++; - array[last_index] = i; - last_index++; - return (i); - } else { - return (0); - } + auto *i = new DLItem(data, last_index, pos->previous, pos); + pos->previous->next = i; + pos->previous = i; + this->number_of_items++; + array[last_index] = i; + last_index++; + return i; } //privates delete template L_DATA DL_Indexed_List::pDelete(DLItem *i) { + assert(this->number_of_items > 0); L_DATA data = i->item; i->previous->next = i->next; i->next->previous = i->previous; array[i->index] = 0; last_index = i->index; - delete (i); + delete i; this->number_of_items--; - return (data); + return data; } template L_DATA DL_Indexed_List::Push(L_DATA data) { DLItem *tmp; tmp = pInsert(data, this->tail); - if (tmp) { - return (tmp->item); - } - return (0); + return tmp->item; } template L_DATA DL_Indexed_List::Pop() { - return (pDelete(this->tail->previous)); + return pDelete(this->tail->previous); } template -L_DATA DL_Indexed_List::Get(unsigned long pos) { +L_DATA DL_Indexed_List::Get(igraph_integer_t pos) { if (pos > this->number_of_items - 1) { - return (0); + return 0; } - return (array[pos]->item); -} - -//####################################################################################### - -//************************************************************************************************************ -template -ClusterList::ClusterList() : DLList() { - links_out_of_cluster = 0; - links_inside_cluster = 0; - frequency = 1; - cluster_energy = 1e30; - candidates = new DLList(); - marker = 0; -} - -template -ClusterList::~ClusterList() { - while (candidates->Size()) { - candidates->Pop(); - } - delete candidates; -} - - -template -bool ClusterList::operator==(ClusterList &b) { - bool found = false; - L_DATA n_cur, n_cur_b; - DLList_Iter a_iter, b_iter; - - if (this->Size() != b.Size()) { - return false; - } - - n_cur = a_iter.First(this); - while (!(a_iter.End())) { - found = false; - n_cur_b = b_iter.First(&b); - while (!(b_iter.End()) && !found) { - if (n_cur == n_cur_b) { - found = true; - } - n_cur_b = b_iter.Next(); - } - if (!found) { - return false; - } - n_cur = a_iter.Next(); - } - return (found); -} -//A -bool ClusterList::operator<(ClusterList &b) { - bool found = false; - L_DATA n_cur, n_cur_b; - DLList_Iter a_iter, b_iter; - - if (this->Size() >= b.Size()) { - return false; - } - n_cur = a_iter.First(this); - while (!(a_iter.End())) { - found = false; - n_cur_b = b_iter.First(&b); - while (!(b_iter.End()) && !found) { - if (n_cur == n_cur_b) { - found = true; - } - n_cur_b = b_iter.Next(); - } - if (!found) { - return false; - } - n_cur = a_iter.Next(); - } - return (found); + return array[pos]->item; } //##################################################################################### -template -DLList_Iter::DLList_Iter() { - list = NULL; - current = NULL; - end_reached = true; -} template L_DATA DLList_Iter::Next() { @@ -911,7 +529,7 @@ L_DATA DLList_Iter::Previous() { } template -L_DATA DLList_Iter::First(DLList *l) { +L_DATA DLList_Iter::First(const DLList *l) { list = l; current = list->head->next; if (current == (list->tail)) { @@ -923,7 +541,7 @@ L_DATA DLList_Iter::First(DLList *l) { } template -L_DATA DLList_Iter::Last(DLList *l) { +L_DATA DLList_Iter::Last(const DLList *l) { list = l; current = list->tail->previous; if (current == (list->head)) { diff --git a/src/vendor/cigraph/src/community/spinglass/NetRoutines.cpp b/src/vendor/cigraph/src/community/spinglass/NetRoutines.cpp index aeba0d00f80..67e4298bab8 100644 --- a/src/vendor/cigraph/src/community/spinglass/NetRoutines.cpp +++ b/src/vendor/cigraph/src/community/spinglass/NetRoutines.cpp @@ -46,226 +46,36 @@ #include "igraph_types.h" #include "igraph_interface.h" -#include "igraph_conversion.h" -igraph_error_t igraph_i_read_network(const igraph_t *graph, - const igraph_vector_t *weights, - network *net, igraph_bool_t use_weights, - unsigned int states) { +igraph_error_t igraph_i_read_network_spinglass( + const igraph_t *graph, const igraph_vector_t *weights, + network *net, igraph_bool_t use_weights) { - double av_k = 0.0, sum_weight = 0.0, min_weight = 1e60, max_weight = -1e60; - unsigned long min_k = 999999999, max_k = 0; - char name[255]; - NNode *node1, *node2; - DLList_Iter iter; - igraph_vector_int_t edgelist; igraph_integer_t no_of_nodes = igraph_vcount(graph); igraph_integer_t no_of_edges = igraph_ecount(graph); - igraph_integer_t ii; - const char *empty = ""; + double sum_weight; - IGRAPH_VECTOR_INT_INIT_FINALLY(&edgelist, no_of_edges * 2); - IGRAPH_CHECK(igraph_get_edgelist(graph, &edgelist, 0 /* rowwise */)); - - for (ii = 0; ii < no_of_nodes; ii++) { - net->node_list->Push(new NNode(ii, 0, net->link_list, empty, states)); + for (igraph_integer_t vid = 0; vid < no_of_nodes; vid++) { + char name[SPINGLASS_MAX_NAME_LEN]; + snprintf(name, sizeof(name) / sizeof(name[0]), "%" IGRAPH_PRId "", vid+1); + net->node_list.Push(new NNode(vid, 0, &net->link_list, name)); } - for (ii = 0; ii < no_of_edges; ii++) { - igraph_integer_t i1 = VECTOR(edgelist)[2 * ii]; - igraph_integer_t i2 = VECTOR(edgelist)[2 * ii + 1]; - igraph_real_t Links; - if (use_weights) { - Links = VECTOR(*weights)[ii]; - } else { - Links = 1.0; - } - - node1 = net->node_list->Get(i1); - snprintf(name, sizeof(name) / sizeof(name[0]), "%" IGRAPH_PRId "", i1+1); - node1->Set_Name(name); + sum_weight = 0.0; + for (igraph_integer_t eid = 0; eid < no_of_edges; eid++) { + igraph_integer_t v1 = IGRAPH_FROM(graph, eid); + igraph_integer_t v2 = IGRAPH_TO(graph, eid); + igraph_real_t w = use_weights ? VECTOR(*weights)[eid] : 1.0; - node2 = net->node_list->Get(i2); - snprintf(name, sizeof(name) / sizeof(name[0]), "%" IGRAPH_PRId "", i2+1); - node2->Set_Name(name); + NNode *node1 = net->node_list.Get(v1); + NNode *node2 = net->node_list.Get(v2); - node1->Connect_To(node2, Links); + node1->Connect_To(node2, w); - if (Links < min_weight) { - min_weight = Links; - } - if (Links > max_weight) { - max_weight = Links; - } - sum_weight += Links; + sum_weight += w; } - IGRAPH_FINALLY_CLEAN(1); - igraph_vector_int_destroy(&edgelist); - - node1 = iter.First(net->node_list); - while (!iter.End()) { - if (node1->Get_Degree() > max_k) { - max_k = node1->Get_Degree(); - } - if (node1->Get_Degree() < min_k) { - min_k = node1->Get_Degree(); - } - av_k += node1->Get_Degree(); - node1 = iter.Next(); - } - net->av_k = av_k / double(net->node_list->Size()); net->sum_weights = sum_weight; - net->av_weight = sum_weight / double(net->link_list->Size()); - net->min_k = min_k; - net->max_k = max_k; - net->min_weight = min_weight; - net->max_weight = max_weight; - net->sum_bids = 0; - net->min_bids = 0; - net->max_bids = 0; return IGRAPH_SUCCESS; } - -//############################################################################################################### -void reduce_cliques(DLList*> *global_cluster_list, FILE *file) { - unsigned long size; - ClusterList *c_cur, *largest_c = NULL; - DLList*> *subsets; - DLList_Iter*> c_iter, sub_iter; - DLList_Iter iter; - NNode *n_cur; - - if (!(global_cluster_list->Size())) { - return; - } - //wir suchen den groessten Cluster - - c_cur = c_iter.First(global_cluster_list); - size = 0; - while (!(c_iter.End())) { - if (c_cur->Size() > size) { - size = c_cur->Size(); - largest_c = c_cur; - } - c_cur = c_iter.Next(); - } -// printf("Groesster Cluster hat %u Elemente.\n",largest_c->Size()); - - //Schauen, ob es Teilmengen gibt, die ebenfalls gefunden wurden - subsets = new DLList*>(); - c_cur = c_iter.First(global_cluster_list); - while (!(c_iter.End())) { - if ((*c_cur < *largest_c || *c_cur == *largest_c) && c_cur != largest_c) { //alle echten Teilcluster von largest_c und die doppelten - subsets->Push(c_cur); - } - c_cur = c_iter.Next(); - } - // die gefundenen Subsets werden aus der cluster_liste geloescht - while (subsets->Size()) { - global_cluster_list->fDelete(subsets->Pop()); - } - delete subsets; - // Dann schreiben wir den groessten Cluster in das File - fprintf(file, "Energie: %1.12f Nodes:%3lu - ", largest_c->Get_Energy(), largest_c->Size()); - - n_cur = iter.First(largest_c); - while (!(iter.End())) { - fprintf(file, "%s", n_cur->Get_Name()); - n_cur = iter.Next(); - if (n_cur) { - fprintf(file, ", "); - } - } - fprintf(file, "\n"); - - - //Schliesslich schmeissen wir noch den eben gefundenen groessten Cluster raus - global_cluster_list->fDelete(largest_c); - //und dann geht es von vorn mit der Reduzierten ClusterListe los - reduce_cliques(global_cluster_list, file); - -} -//################################################################################## -void reduce_cliques2(network *net, bool only_double, long marker) { - unsigned long size; - ClusterList *c_cur, *largest_c = NULL; - DLList_Iter*> c_iter; - do { - //wir suchen den groessten, nicht markierten Cluster - size = 0; - c_cur = c_iter.First(net->cluster_list); - while (!(c_iter.End())) { - if ((c_cur->Size() > size) && (c_cur->Get_Marker() != marker)) { - size = c_cur->Size(); - largest_c = c_cur; - } - c_cur = c_iter.Next(); - } - // printf("Groesster Cluster hat %u Elemente.\n",largest_c->Size()); - //Schauen, ob es Teilmengen gibt, die ebenfalls gefunden wurden - c_cur = c_iter.First(net->cluster_list); - while (!(c_iter.End())) { - if (((!only_double && (*c_cur < *largest_c)) || (*c_cur == *largest_c)) && (c_cur != largest_c)) { //alle echten Teilcluster von largest_c und die doppelten - net->cluster_list->fDelete(c_cur); - while (c_cur->Get_Candidates()->Size()) { - c_cur->Get_Candidates()->Pop(); - } - while (c_cur->Size()) { - c_cur->Pop(); // die knoten aber nicht loeschen!! - } - delete c_cur; // nicht vergessen, die global geloeschte Clusterliste zu loeschen - } - c_cur = c_iter.Next(); - } - //Schliesslich markieren wir noch den eben gefundenen groessten Cluster - largest_c->Set_Marker(marker); - } while (size); -} - -//################################################################################################## -unsigned long iterate_nsf_hierarchy(NNode *parent, unsigned long depth, FILE *file) { - NNode* next_node; - unsigned long newdepth, maxdepth; - bool first = true; - DLList_Iter *iter; - maxdepth = newdepth = depth; - iter = new DLList_Iter; - next_node = iter->First(parent->Get_Neighbours()); - while (!(iter->End())) { - if (next_node->Get_Marker() > parent->Get_Marker()) { // wir gehen nach unten - if (first) { - fprintf(file, ",("); // eine Neue Klammer auf - } - if (first) { - fprintf(file, "%s", next_node->Get_Name()); // nur vor dem ersten kein Komma - } else { - fprintf(file, ",%s", next_node->Get_Name()); // sonst immer mit Komma - } - first = false; - newdepth = iterate_nsf_hierarchy(next_node, depth + 1, file); - if (maxdepth < newdepth) { - maxdepth = newdepth; - } - } - next_node = iter->Next(); - } - if (!first) { - fprintf(file, ")"); //hat es ueberhaupt einen gegeben? - } - //dann klamer zu! - delete iter; - return maxdepth; -} - -//################################################################ -void clear_all_markers(network *net) { - DLList_Iter iter; - NNode *n_cur; - n_cur = iter.First(net->node_list); - while (!iter.End()) { - n_cur->Set_Marker(0); - n_cur = iter.Next(); - } -} diff --git a/src/vendor/cigraph/src/community/spinglass/NetRoutines.h b/src/vendor/cigraph/src/community/spinglass/NetRoutines.h index 53a4e51aa34..98fd5fef453 100644 --- a/src/vendor/cigraph/src/community/spinglass/NetRoutines.h +++ b/src/vendor/cigraph/src/community/spinglass/NetRoutines.h @@ -48,13 +48,8 @@ #include "igraph_types.h" #include "igraph_datatype.h" -igraph_error_t igraph_i_read_network(const igraph_t *graph, - const igraph_vector_t *weights, - network *net, igraph_bool_t use_weights, - unsigned int states); - -void reduce_cliques(DLList*>*, FILE *file); -void reduce_cliques2(network*, bool, long ); -void clear_all_markers(network *net); +igraph_error_t igraph_i_read_network_spinglass( + const igraph_t *graph, const igraph_vector_t *weights, + network *net, igraph_bool_t use_weights); #endif diff --git a/src/vendor/cigraph/src/community/spinglass/clustertool.cpp b/src/vendor/cigraph/src/community/spinglass/clustertool.cpp index 0a13afc9dc1..537a0df6f39 100644 --- a/src/vendor/cigraph/src/community/spinglass/clustertool.cpp +++ b/src/vendor/cigraph/src/community/spinglass/clustertool.cpp @@ -83,9 +83,6 @@ static igraph_error_t igraph_i_community_spinglass_negative( igraph_real_t coolfact, igraph_spincomm_update_t update_rule, igraph_real_t gamma, - /* igraph_matrix_t *adhesion, */ - /* igraph_matrix_t *normalised_adhesion, */ - /* igraph_real_t *polarization, */ igraph_real_t gamma_minus); /** @@ -203,7 +200,7 @@ igraph_error_t igraph_community_spinglass(const igraph_t *graph, gamma_minus); break; default: - IGRAPH_ERROR("Unknown `implementation' in spinglass community finding", + IGRAPH_ERROR("Unknown implementation in spinglass community detection.", IGRAPH_EINVAL); } ); @@ -225,7 +222,7 @@ static igraph_error_t igraph_i_community_spinglass_orig( igraph_real_t gamma) { igraph_integer_t no_of_nodes = igraph_vcount(graph); - unsigned long changes, runs; + igraph_integer_t changes, runs; igraph_bool_t use_weights = false; bool zeroT; double kT, acc, prob; @@ -233,30 +230,39 @@ static igraph_error_t igraph_i_community_spinglass_orig( /* Check arguments */ if (spins < 2) { - IGRAPH_ERROR("Number of spins must be at least 2", IGRAPH_EINVAL); + IGRAPH_ERROR("Number of spins must be at least 2.", IGRAPH_EINVAL); } if (update_rule != IGRAPH_SPINCOMM_UPDATE_SIMPLE && update_rule != IGRAPH_SPINCOMM_UPDATE_CONFIG) { - IGRAPH_ERROR("Invalid update rule", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid update rule for spinglass community detection.", IGRAPH_EINVAL); } if (weights) { if (igraph_vector_size(weights) != igraph_ecount(graph)) { - IGRAPH_ERROR("Invalid weight vector length", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid weight vector length.", IGRAPH_EINVAL); } - use_weights = 1; + use_weights = true; if (igraph_vector_min(weights) < 0) { - IGRAPH_ERROR("Weights must not be negative when using the original implementation of spinglass communities. Select the implementation meant for negative weights.", IGRAPH_EINVAL); + IGRAPH_ERROR( + "Weights must not be negative when using the original implementation of spinglass communities. " + "Select the implementation meant for negative weights.", + IGRAPH_EINVAL); } } if (coolfact < 0 || coolfact >= 1.0) { - IGRAPH_ERROR("Invalid cooling factor", IGRAPH_EINVAL); + IGRAPH_ERROR("Cooling factor must be positive and strictly smaller than 1.", IGRAPH_EINVAL); } if (gamma < 0.0) { - IGRAPH_ERROR("Invalid gamma value", IGRAPH_EINVAL); + IGRAPH_ERROR("Gamma value must not be negative.", IGRAPH_EINVAL); } - if (starttemp / stoptemp < 1.0) { - IGRAPH_ERROR("starttemp should be larger in absolute value than stoptemp", - IGRAPH_EINVAL); + if ( !(starttemp == 0 && stoptemp == 0) ) { + if (! (starttemp > 0 && stoptemp > 0)) { + IGRAPH_ERROR("Starting and stopping temperatures must be both positive or both zero.", + IGRAPH_EINVAL); + } + if (starttemp <= stoptemp) { + IGRAPH_ERROR("The starting temperature must be larger than the stopping temperature.", + IGRAPH_EINVAL); + } } /* The spinglass algorithm does not handle the trivial cases of the @@ -267,7 +273,7 @@ static igraph_error_t igraph_i_community_spinglass_orig( igraph_vector_int_fill(membership, 0); } if (modularity) { - IGRAPH_CHECK(igraph_modularity(graph, membership, 0, 1, igraph_is_directed(graph), modularity)); + IGRAPH_CHECK(igraph_modularity(graph, membership, nullptr, 1, igraph_is_directed(graph), modularity)); } if (temperature) { *temperature = stoptemp; @@ -284,19 +290,19 @@ static igraph_error_t igraph_i_community_spinglass_orig( igraph_bool_t conn; IGRAPH_CHECK(igraph_is_connected(graph, &conn, IGRAPH_WEAK)); if (!conn) { - IGRAPH_ERROR("Cannot work with unconnected graph", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot work with unconnected graph.", IGRAPH_EINVAL); } network net; /* Transform the igraph_t */ - IGRAPH_CHECK(igraph_i_read_network(graph, weights, - &net, use_weights, 0)); + IGRAPH_CHECK(igraph_i_read_network_spinglass(graph, weights, + &net, use_weights)); - prob = 2.0 * net.sum_weights / double(net.node_list->Size()) - / double(net.node_list->Size() - 1); + prob = 2.0 * net.sum_weights / double(net.node_list.Size()) + / double(net.node_list.Size() - 1); - PottsModel pm(&net, (unsigned int)spins, update_rule); + PottsModel pm(&net, spins, update_rule); /* initialize the random number generator */ RNG_BEGIN(); @@ -428,8 +434,7 @@ igraph_error_t igraph_community_spinglass_single(const igraph_t *graph, igraph_real_t gamma) { IGRAPH_HANDLE_EXCEPTIONS( igraph_bool_t use_weights = false; - double prob; - char startnode[255]; + char startnode[SPINGLASS_MAX_NAME_LEN]; /* Check arguments */ @@ -463,23 +468,20 @@ igraph_error_t igraph_community_spinglass_single(const igraph_t *graph, network net; /* Transform the igraph_t */ - IGRAPH_CHECK(igraph_i_read_network(graph, weights, - &net, use_weights, 0)); + IGRAPH_CHECK(igraph_i_read_network_spinglass(graph, weights, + &net, use_weights)); - prob = 2.0 * net.sum_weights / double(net.node_list->Size()) - / double(net.node_list->Size() - 1); - - PottsModel pm(&net, (unsigned int)spins, update_rule); + PottsModel pm(&net, spins, update_rule); /* initialize the random number generator */ RNG_BEGIN(); - /* to be exected, if we want to find the community around a particular node*/ + /* to be expected, if we want to find the community around a particular node*/ /* the initial conf is needed, because otherwise, the degree of the nodes is not in the weight property, stupid!!! */ pm.assign_initial_conf(-1); - snprintf(startnode, 255, "%" IGRAPH_PRId "", vertex + 1); - pm.FindCommunityFromStart(gamma, prob, startnode, community, + snprintf(startnode, sizeof(startnode) / sizeof(startnode[0]), "%" IGRAPH_PRId "", vertex + 1); + pm.FindCommunityFromStart(gamma, startnode, community, cohesion, adhesion, inner_links, outer_links); RNG_END(); @@ -502,13 +504,10 @@ static igraph_error_t igraph_i_community_spinglass_negative( igraph_real_t coolfact, igraph_spincomm_update_t update_rule, igraph_real_t gamma, - /* igraph_matrix_t *adhesion, */ - /* igraph_matrix_t *normalised_adhesion, */ - /* igraph_real_t *polarization, */ igraph_real_t gamma_minus) { igraph_integer_t no_of_nodes = igraph_vcount(graph); - unsigned long changes, runs; + igraph_integer_t runs; igraph_bool_t use_weights = false; bool zeroT; double kT, acc; @@ -518,32 +517,38 @@ static igraph_error_t igraph_i_community_spinglass_negative( /* Check arguments */ if (parupdate) { - IGRAPH_ERROR("Parallel spin update not implemented with " - "negative gamma", IGRAPH_UNIMPLEMENTED); + IGRAPH_ERROR("Parallel spin update not implemented with negative weights.", + IGRAPH_UNIMPLEMENTED); } if (spins < 2) { - IGRAPH_ERROR("Number of spins must be at least 2", IGRAPH_EINVAL); + IGRAPH_ERROR("Number of spins must be at least 2.", IGRAPH_EINVAL); } if (update_rule != IGRAPH_SPINCOMM_UPDATE_SIMPLE && update_rule != IGRAPH_SPINCOMM_UPDATE_CONFIG) { - IGRAPH_ERROR("Invalid update rule", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid update rule for spinglass community detection.", IGRAPH_EINVAL); } if (weights) { if (igraph_vector_size(weights) != igraph_ecount(graph)) { - IGRAPH_ERROR("Invalid weight vector length", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid weight vector length.", IGRAPH_EINVAL); } - use_weights = 1; + use_weights = true; } if (coolfact < 0 || coolfact >= 1.0) { - IGRAPH_ERROR("Invalid cooling factor", IGRAPH_EINVAL); + IGRAPH_ERROR("Cooling factor must be positive and strictly smaller than 1.", IGRAPH_EINVAL); } if (gamma < 0.0) { - IGRAPH_ERROR("Invalid gamma value", IGRAPH_EINVAL); + IGRAPH_ERROR("Gamma value must not be negative.", IGRAPH_EINVAL); } - if (starttemp / stoptemp < 1.0) { - IGRAPH_ERROR("starttemp should be larger in absolute value than stoptemp", - IGRAPH_EINVAL); + if ( !(starttemp == 0 && stoptemp == 0) ) { + if (! (starttemp > 0 && stoptemp > 0)) { + IGRAPH_ERROR("Starting and stopping temperatures must be both positive or both zero.", + IGRAPH_EINVAL); + } + if (starttemp <= stoptemp) { + IGRAPH_ERROR("The starting temperature must be larger than the stopping temperature.", + IGRAPH_EINVAL); + } } /* The spinglass algorithm does not handle the trivial cases of the @@ -554,7 +559,7 @@ static igraph_error_t igraph_i_community_spinglass_negative( igraph_vector_int_fill(membership, 0); } if (modularity) { - IGRAPH_CHECK(igraph_modularity(graph, membership, 0, 1, igraph_is_directed(graph), modularity)); + IGRAPH_CHECK(igraph_modularity(graph, membership, nullptr, 1, igraph_is_directed(graph), modularity)); } if (temperature) { *temperature = stoptemp; @@ -571,7 +576,7 @@ static igraph_error_t igraph_i_community_spinglass_negative( igraph_bool_t conn; IGRAPH_CHECK(igraph_is_connected(graph, &conn, IGRAPH_WEAK)); if (!conn) { - IGRAPH_ERROR("Cannot work with unconnected graph", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot work with unconnected graph.", IGRAPH_EINVAL); } if (weights && igraph_vector_size(weights) > 0) { @@ -591,12 +596,12 @@ static igraph_error_t igraph_i_community_spinglass_negative( network net; /* Transform the igraph_t */ - IGRAPH_CHECK(igraph_i_read_network(graph, weights, - &net, use_weights, 0)); + IGRAPH_CHECK(igraph_i_read_network_spinglass(graph, weights, + &net, use_weights)); bool directed = igraph_is_directed(graph); - PottsModelN pm(&net, (unsigned int)spins, directed); + PottsModelN pm(&net, spins, directed); /* initialize the random number generator */ RNG_BEGIN(); @@ -614,21 +619,15 @@ static igraph_error_t igraph_i_community_spinglass_negative( pm.assign_initial_conf(true); runs = 0; - changes = 1; - acc = 0; - while (changes > 0 && (kT / stoptemp > 1.0 || (zeroT && runs < 150))) { - + while (kT / stoptemp > 1.0 || (zeroT && runs < 150)) { IGRAPH_ALLOW_INTERRUPTION(); runs++; kT = kT * coolfact; acc = pm.HeatBathLookup(gamma, gamma_minus, kT, 50); if (acc < (1.0 - 1.0 / double(spins)) * 0.001) { - changes = 0; - } else { - changes = 1; + break; } - } /* while loop */ /* These are needed, otherwise 'modularity' is not calculated */ @@ -638,7 +637,7 @@ static igraph_error_t igraph_i_community_spinglass_negative( IGRAPH_MATRIX_INIT_FINALLY(&normalized_adhesion, 0, 0); pm.WriteClusters(modularity, temperature, csize, membership, &adhesion, &normalized_adhesion, &polarization, - kT, d_p, d_n, gamma, gamma_minus); + kT, d_p, d_n); igraph_matrix_destroy(&normalized_adhesion); igraph_matrix_destroy(&adhesion); IGRAPH_FINALLY_CLEAN(2); diff --git a/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.cpp b/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.cpp index 347d83b15f8..f454154e4dd 100644 --- a/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.cpp +++ b/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.cpp @@ -53,15 +53,12 @@ using namespace std; //################################################################################################# -PottsModel::PottsModel(network *n, unsigned long qvalue, int m) : Qmatrix(qvalue+1), acceptance(0) +PottsModel::PottsModel(network *n, igraph_integer_t qvalue, int m) : + net(n), q(qvalue), operation_mode(m), Qmatrix(qvalue+1) { DLList_Iter iter; - NNode *n_cur; - unsigned long *i_ptr; - net = n; - q = qvalue; - operation_mode = m; - k_max = 0; + const NNode *n_cur; + igraph_integer_t *i_ptr; //needed in calculating modularity Qa = new double[q + 1]; //weights for each spin state needed in Monte Carlo process @@ -70,23 +67,20 @@ PottsModel::PottsModel(network *n, unsigned long qvalue, int m) : Qmatrix(qvalue color_field = new double[q + 1]; neighbours = new double[q + 1]; - num_of_nodes = net->node_list->Size(); - num_of_links = net->link_list->Size(); + num_of_nodes = net->node_list.Size(); + num_of_links = net->link_list.Size(); - n_cur = iter.First(net->node_list); - //these lists are needed to keep track of spin states for parallel update mode - new_spins = new DL_Indexed_List(); - previous_spins = new DL_Indexed_List(); + n_cur = iter.First(&net->node_list); while (!iter.End()) { if (k_max < n_cur->Get_Degree()) { k_max = n_cur->Get_Degree(); } - i_ptr = new unsigned long; + i_ptr = new igraph_integer_t; *i_ptr = 0; - new_spins->Push(i_ptr); - i_ptr = new unsigned long; + new_spins.Push(i_ptr); + i_ptr = new igraph_integer_t; *i_ptr = 0; - previous_spins->Push(i_ptr); + previous_spins.Push(i_ptr); n_cur = iter.Next(); } } @@ -97,10 +91,8 @@ PottsModel::~PottsModel() { /* The DLItem destructor does not delete its item currently, because of some bad design. As a workaround, we delete them here by hand */ - new_spins->delete_items(); - previous_spins->delete_items(); - delete new_spins; - delete previous_spins; + new_spins.delete_items(); + previous_spins.delete_items(); delete [] Qa; delete [] weights; delete [] color_field; @@ -112,26 +104,21 @@ PottsModel::~PottsModel() { //when called with positve one. //This may be handy, if you want to warm up the network. //#################################################### -unsigned long PottsModel::assign_initial_conf(igraph_integer_t spin) { +igraph_integer_t PottsModel::assign_initial_conf(igraph_integer_t spin) { igraph_integer_t s; DLList_Iter iter; DLList_Iter l_iter; NNode *n_cur; - NLink *l_cur; + const NLink *l_cur; double sum_weight; - double av_k_squared = 0.0; - double av_k = 0.0; - IGRAPH_UNUSED(av_k_squared); /* We mark it as unused to prevent warnings about unused-but-set-variables. */ - IGRAPH_UNUSED(av_k); /* We mark it as unused to prevent warnings about unused-but-set-variables. */ -// printf("Assigning initial configuration...\n"); // initialize colorfield - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { color_field[i] = 0.0; } // total_degree_sum = 0.0; - n_cur = iter.First(net->node_list); + n_cur = iter.First(&net->node_list); while (!iter.End()) { if (spin < 0) { s = RNG_INTEGER(1, q); @@ -148,8 +135,6 @@ unsigned long PottsModel::assign_initial_conf(igraph_integer_t spin) { // we set the sum of the weights or the degree as the weight of the node, this way // we do not have to calculate it again. n_cur->Set_Weight(sum_weight); - av_k_squared += sum_weight * sum_weight; - av_k += sum_weight; // in case we want all links to be contribute equally - parameter gamm=fixed if (operation_mode == 0) { @@ -161,42 +146,10 @@ unsigned long PottsModel::assign_initial_conf(igraph_integer_t spin) { total_degree_sum += sum_weight; n_cur = iter.Next(); } - av_k_squared /= double(net->node_list->Size()); - av_k /= double(net->node_list->Size()); - // total_degree_sum-=av_k_squared/av_k; -// printf("Total Degree Sum=2M=%f\n",total_degree_sum); - return net->node_list->Size(); -} -//##################################################################### -//If I ever manage to write a decent LookUp function, it will be here -//##################################################################### -unsigned long PottsModel::initialize_lookup(double kT, double gamma) { - IGRAPH_UNUSED(kT); - IGRAPH_UNUSED(gamma); - /* - double beta; - // the look-up table contains all entries of exp(-beta(-neighbours+gamma*h)) - // as needed in the HeatBath algorithm - beta=1.0/kT; - for (long w=0; w<=k_max+num_of_nodes; w++) - { - neg_lookup[w]=exp(-beta*-w - } - delta_ij[0]=1.0; - for (long w=-num_of_nodes-k_max; w<=k_max+num_of_nodes; w++) - { - - } - // wenn wir spaeter exp(-1/kT*gamma*(nk+1-nj) fuer eine spin-flip von j nach k benoetigen schauen wir nur noch hier nach - for (unsigned long n=1; n<=num_of_nodes; n++) - { - gamma_term[n]=exp(-double(n)/kT*gamma); - } - gamma_term[0]=1.0; - */ - return 1; + return net->node_list.Size(); } + //##################################################################### // Q denotes the modularity of the network // This function calculates it initially @@ -207,9 +160,9 @@ unsigned long PottsModel::initialize_lookup(double kT, double gamma) { double PottsModel::initialize_Qmatrix() { DLList_Iter l_iter; NLink *l_cur; - unsigned long i, j; + igraph_integer_t i, j; //initialize with zeros - num_of_links = net->link_list->Size(); + num_of_links = net->link_list.Size(); for (i = 0; i <= q; i++) { Qa[i] = 0.0; for (j = i; j <= q; j++) { @@ -219,11 +172,10 @@ double PottsModel::initialize_Qmatrix() { } //go over all links and make corresponding entries in Q matrix //An edge connecting state i wiht state j will get an entry in Qij and Qji - l_cur = l_iter.First(net->link_list); + l_cur = l_iter.First(&net->link_list); while (!l_iter.End()) { i = l_cur->Get_Start()->Get_ClusterIndex(); j = l_cur->Get_End()->Get_ClusterIndex(); - //printf("%d %d\n",i,j); Qmatrix[i][j] += l_cur->Get_Weight(); Qmatrix[j][i] += l_cur->Get_Weight(); @@ -243,53 +195,13 @@ double PottsModel::initialize_Qmatrix() { //#################################################################### double PottsModel::calculate_Q() { double Q = 0.0; - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { Q += Qmatrix[i][i] - Qa[i] * Qa[i] / double(2.0 * net->sum_weights); - if ((Qa[i] < 0.0) || Qmatrix[i][i] < 0.0) { -// printf("Negatives Qa oder Qii\n\n\n"); - //printf("Press any key to continue\n\n"); - //cin >> Q; - } } Q /= double(2.0 * net->sum_weights); return Q; } -double PottsModel::calculate_genQ(double gamma) { - double Q = 0.0; - for (unsigned long i = 0; i <= q; i++) { - Q += Qmatrix[i][i] - gamma * Qa[i] * Qa[i] / double(2.0 * net->sum_weights); - if ((Qa[i] < 0.0) || Qmatrix[i][i] < 0.0) { -// printf("Negatives Qa oder Qii\n\n\n"); - //printf("Press any key to continue\n\n"); - //cin >> Q; - } - } - Q /= double(2.0 * net->sum_weights); - return Q; -} -//####################################################################### -// This function calculates the Energy for the standard Hamiltonian -// given a particular value of gamma and the current spin states -// ##################################################################### -double PottsModel::calculate_energy(double gamma) { - double e = 0.0; - DLList_Iter l_iter; - NLink *l_cur; - l_cur = l_iter.First(net->link_list); - //every in-cluster edge contributes -1 - while (!l_iter.End()) { - if (l_cur->Get_Start()->Get_ClusterIndex() == l_cur->Get_End()->Get_ClusterIndex()) { - e--; - } - l_cur = l_iter.Next(); - } - //and the penalty term contributes according to cluster sizes - for (unsigned long i = 1; i <= q; i++) { - e += gamma * 0.5 * double(color_field[i]) * double((color_field[i] - 1)); - } - energy = e; - return e; -} + //########################################################################## // We would like to start from a temperature with at least 95 of all proposed // spin changes accepted in 50 sweeps over the network @@ -307,13 +219,9 @@ double PottsModel::FindStartTemp(double gamma, double prob, double ts) { // state is with prob. 1/q the old state. while (acceptance < (1.0 - 1.0 / double(q)) * 0.95) { //want 95% acceptance kT = kT * 1.1; - // if I ever have a lookup table, it will need initialization for every kT - //initialize_lookup(kT,k_max,net->node_list->Size()); HeatBathParallelLookup(gamma, prob, kT, 50); -// printf("kT=%f acceptance=%f\n", kT, acceptance); } kT *= 1.1; // just to be sure... -// printf("Starting with acceptance ratio: %1.6f bei kT=%2.4f\n",acceptance,kT); return kT; } @@ -323,18 +231,16 @@ double PottsModel::FindStartTemp(double gamma, double prob, double ts) { //max sweeps is the maximum number of sweeps it should perform, //if it does not converge earlier //############################################################## -long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsigned int max_sweeps) { - DLList_Iter iter, net_iter; +igraph_integer_t PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsigned int max_sweeps) { + DLList_Iter net_iter; DLList_Iter l_iter; - DLList_Iter i_iter, i_iter2; + DLList_Iter i_iter, i_iter2; NNode *node, *n_cur; NLink *l_cur; unsigned int sweep; - unsigned long *SPIN, *P_SPIN, old_spin, spin, new_spin, spin_opt; - // long h; // degree; - unsigned long changes; + igraph_integer_t *SPIN, *P_SPIN, old_spin, new_spin, spin_opt; + igraph_integer_t changes; double h, delta = 0, deltaE, deltaEmin, w, degree; - //HugeArray neighbours; bool cyclic = false; sweep = 0; @@ -344,19 +250,18 @@ long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsig sweep++; changes = 0; //Loop over all nodes - node = net_iter.First(net->node_list); - SPIN = i_iter.First(new_spins); + node = net_iter.First(&net->node_list); + SPIN = i_iter.First(&new_spins); while (!net_iter.End()) { // How many neighbors of each type? // set them all zero - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { neighbours[i] = 0; } degree = node->Get_Weight(); //Loop over all links (=neighbours) l_cur = l_iter.First(node->Get_Links()); while (!l_iter.End()) { - //printf("%s %s\n",node->Get_Name(),n_cur->Get_Name()); w = l_cur->Get_Weight(); if (node == l_cur->Get_Start()) { n_cur = l_cur->Get_End(); @@ -368,7 +273,6 @@ long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsig } //Search optimal Spin old_spin = node->Get_ClusterIndex(); - //degree=node->Get_Degree(); switch (operation_mode) { case 0: { delta = 1.0; @@ -379,12 +283,14 @@ long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsig delta = degree; break; } + default: + IGRAPH_FATAL("Must not reach here."); } spin_opt = old_spin; deltaEmin = 0.0; - for (spin = 1; spin <= q; spin++) { // all possible spin states + for (igraph_integer_t spin = 1; spin <= q; spin++) { // all possible spin states if (spin != old_spin) { h = color_field[spin] + delta - color_field[old_spin]; deltaE = double(neighbours[old_spin] - neighbours[spin]) + gamma * prob * double(h); @@ -403,9 +309,9 @@ long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsig //------------------------------- //Now set all spins to new values - node = net_iter.First(net->node_list); - SPIN = i_iter.First(new_spins); - P_SPIN = i_iter2.First(previous_spins); + node = net_iter.First(&net->node_list); + SPIN = i_iter.First(&new_spins); + P_SPIN = i_iter2.First(&previous_spins); while (!net_iter.End()) { old_spin = node->Get_ClusterIndex(); new_spin = *SPIN; @@ -449,7 +355,6 @@ long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsig // In case of a cyclic attractor, we want to interrupt if (cyclic) { -// printf("Cyclic attractor!\n"); acceptance = 0.0; return 0; } else { @@ -462,40 +367,32 @@ long PottsModel::HeatBathParallelLookupZeroTemp(double gamma, double prob, unsig //randomly //################################################################################### double PottsModel::HeatBathLookupZeroTemp(double gamma, double prob, unsigned int max_sweeps) { - DLList_Iter iter; DLList_Iter l_iter; - DLList_Iter i_iter, i_iter2; NNode *node, *n_cur; NLink *l_cur; - unsigned long new_spin, spin_opt, old_spin, spin; + igraph_integer_t new_spin, spin_opt, old_spin; unsigned int sweep; - long r;// degree; - unsigned long changes; + igraph_integer_t r; + igraph_integer_t changes; double delta = 0, h, deltaE, deltaEmin, w, degree; - //HugeArray neighbours; sweep = 0; changes = 0; while (sweep < max_sweeps) { sweep++; //ueber alle Knoten im Netz - for (unsigned long n = 0; n < num_of_nodes; n++) { - r = -1; - while ((r < 0) || (r > (long)num_of_nodes - 1)) { - r = RNG_INTEGER(0, num_of_nodes - 1); - } - /* r=long(double(num_of_nodes*double(rand())/double(RAND_MAX+1.0)));*/ - node = net->node_list->Get(r); + for (igraph_integer_t n = 0; n < num_of_nodes; n++) { + r = RNG_INTEGER(0, num_of_nodes - 1); + node = net->node_list.Get(r); // Wir zaehlen, wieviele Nachbarn von jedem spin vorhanden sind // erst mal alles Null setzen - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { neighbours[i] = 0; } degree = node->Get_Weight(); //Loop over all links (=neighbours) l_cur = l_iter.First(node->Get_Links()); while (!l_iter.End()) { - //printf("%s %s\n",node->Get_Name(),n_cur->Get_Name()); w = l_cur->Get_Weight(); if (node == l_cur->Get_Start()) { n_cur = l_cur->Get_End(); @@ -507,7 +404,6 @@ double PottsModel::HeatBathLookupZeroTemp(double gamma, double prob, unsigned in } //Search optimal Spin old_spin = node->Get_ClusterIndex(); - //degree=node->Get_Degree(); switch (operation_mode) { case 0: { delta = 1.0; @@ -518,12 +414,14 @@ double PottsModel::HeatBathLookupZeroTemp(double gamma, double prob, unsigned in delta = degree; break; } + default: + IGRAPH_FATAL("Must not reach here."); } spin_opt = old_spin; deltaEmin = 0.0; - for (spin = 1; spin <= q; spin++) { // alle moeglichen Spins + for (igraph_integer_t spin = 1; spin <= q; spin++) { // alle moeglichen Spins if (spin != old_spin) { h = color_field[spin] + delta - color_field[old_spin]; deltaE = double(neighbours[old_spin] - neighbours[spin]) + gamma * prob * double(h); @@ -571,36 +469,34 @@ double PottsModel::HeatBathLookupZeroTemp(double gamma, double prob, unsigned in //##################################################################################### //This function performs a parallel update at Terperature T //##################################################################################### -long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, unsigned int max_sweeps) { - DLList_Iter iter, net_iter; +igraph_integer_t PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, unsigned int max_sweeps) { + DLList_Iter net_iter; DLList_Iter l_iter; - DLList_Iter i_iter, i_iter2; + DLList_Iter i_iter, i_iter2; NNode *node, *n_cur; NLink *l_cur; - unsigned long new_spin, spin_opt, old_spin; - unsigned long *SPIN, *P_SPIN; + igraph_integer_t new_spin, spin_opt, old_spin; + igraph_integer_t *SPIN, *P_SPIN; unsigned int sweep; - long max_q; - unsigned long changes/*, degree, problemcount */; - //HugeArray neighbours; + igraph_integer_t max_q; + igraph_integer_t changes; double h, delta = 0, norm, r, beta, minweight, prefac = 0, w, degree; bool cyclic = false/*, found*/; - unsigned long number_of_nodes; + igraph_integer_t number_of_nodes; sweep = 0; changes = 1; - number_of_nodes = net->node_list->Size(); + number_of_nodes = net->node_list.Size(); while (sweep < max_sweeps && changes) { cyclic = true; sweep++; changes = 0; //Loop over all nodes - node = net_iter.First(net->node_list); - SPIN = i_iter.First(new_spins); + node = net_iter.First(&net->node_list); + SPIN = i_iter.First(&new_spins); while (!net_iter.End()) { // Initialize neighbours and weights - // problemcount = 0; - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { neighbours[i] = 0; weights[i] = 0; } @@ -609,7 +505,6 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un //Loop over all links (=neighbours) l_cur = l_iter.First(node->Get_Links()); while (!l_iter.End()) { - //printf("%s %s\n",node->Get_Name(),n_cur->Get_Name()); w = l_cur->Get_Weight(); if (node == l_cur->Get_Start()) { n_cur = l_cur->Get_End(); @@ -621,7 +516,6 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un } //Search optimal Spin old_spin = node->Get_ClusterIndex(); - //degree=node->Get_Degree(); switch (operation_mode) { case 0: { prefac = 1.0; @@ -634,12 +528,14 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un delta = degree; break; } + default: + IGRAPH_FATAL("Must not reach here."); } spin_opt = old_spin; beta = 1.0 / kT * prefac; minweight = 0.0; weights[old_spin] = 0.0; - for (unsigned spin = 1; spin <= q; spin++) { // loop over all possible new spins + for (igraph_integer_t spin = 1; spin <= q; spin++) { // loop over all possible new spins if (spin != old_spin) { // only if we have a different than old spin! h = color_field[spin] + delta - color_field[old_spin]; weights[spin] = double(neighbours[old_spin] - neighbours[spin]) + gamma * prob * double(h); @@ -648,7 +544,7 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un } } } // for spin - for (unsigned spin = 1; spin <= q; spin++) { // loop over all possibe spins + for (igraph_integer_t spin = 1; spin <= q; spin++) { // loop over all possibe spins weights[spin] -= minweight; // subtract minweight // to avoid numerical problems with large exponents weights[spin] = exp(-beta * weights[spin]); @@ -657,25 +553,16 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un //now choose a new spin r = RNG_UNIF(0, norm); - /* norm*double(rand())/double(RAND_MAX + 1.0); */ new_spin = 1; - //found = false; - while (/*!found &&*/ new_spin <= q) { + while (new_spin <= q) { if (r <= weights[new_spin]) { spin_opt = new_spin; - // found = true; break; } else { r -= weights[new_spin]; } new_spin++; } - /* - if (!found) { - printf("."); - problemcount++; - } - */ //Put new spin on list *SPIN = spin_opt; @@ -685,9 +572,9 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un //------------------------------- //now update all spins - node = net_iter.First(net->node_list); - SPIN = i_iter.First(new_spins); - P_SPIN = i_iter2.First(previous_spins); + node = net_iter.First(&net->node_list); + SPIN = i_iter.First(&new_spins); + P_SPIN = i_iter2.First(&previous_spins); while (!net_iter.End()) { old_spin = node->Get_ClusterIndex(); new_spin = *SPIN; @@ -727,13 +614,12 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un } // while markov max_q = 0; - for (unsigned long i = 1; i <= q; i++) if (color_field[i] > max_q) { - max_q = long(color_field[i]); + for (igraph_integer_t i = 1; i <= q; i++) if (color_field[i] > max_q) { + max_q = igraph_integer_t(color_field[i]); } //again, we would not like to end up in cyclic attractors if (cyclic && changes) { -// printf("Cyclic attractor!\n"); acceptance = double(changes) / double(number_of_nodes); return 0; } else { @@ -746,37 +632,29 @@ long PottsModel::HeatBathParallelLookup(double gamma, double prob, double kT, un // as the parallel update has its flaws, due to the cyclic attractors //############################################################## double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned int max_sweeps) { - DLList_Iter iter; DLList_Iter l_iter; - DLList_Iter i_iter, i_iter2; NNode *node, *n_cur; NLink *l_cur; - unsigned long new_spin, spin_opt, old_spin; + igraph_integer_t new_spin, spin_opt, old_spin; unsigned int sweep; - long max_q, rn; - unsigned long changes/*, degree, problemcount*/; + igraph_integer_t max_q; + igraph_integer_t rn; + igraph_integer_t changes; double degree, w, delta = 0, h; - //HugeArray neighbours; double norm, r, beta, minweight, prefac = 0; - //bool found; igraph_integer_t number_of_nodes; sweep = 0; changes = 0; - number_of_nodes = net->node_list->Size(); + number_of_nodes = net->node_list.Size(); while (sweep < max_sweeps) { sweep++; //loop over all nodes in network - for (long n = 0; n < number_of_nodes; n++) { - rn = -1; - while ((rn < 0) || (rn > number_of_nodes - 1)) { - rn = RNG_INTEGER(0, number_of_nodes - 1); - } - /* rn=long(double(number_of_nodes*double(rand())/double(RAND_MAX+1.0))); */ + for (igraph_integer_t n = 0; n < number_of_nodes; n++) { + rn = RNG_INTEGER(0, number_of_nodes - 1); - node = net->node_list->Get(rn); + node = net->node_list.Get(rn); // initialize the neighbours and the weights - // problemcount = 0; - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { neighbours[i] = 0.0; weights[i] = 0.0; } @@ -785,7 +663,6 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned //Loop over all links (=neighbours) l_cur = l_iter.First(node->Get_Links()); while (!l_iter.End()) { - //printf("%s %s\n",node->Get_Name(),n_cur->Get_Name()); w = l_cur->Get_Weight(); if (node == l_cur->Get_Start()) { n_cur = l_cur->Get_End(); @@ -799,7 +676,6 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned //Look for optimal spin old_spin = node->Get_ClusterIndex(); - //degree=node->Get_Degree(); switch (operation_mode) { case 0: { prefac = 1.0; @@ -812,12 +688,14 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned delta = degree; break; } + default: + IGRAPH_FATAL("Must not reach here."); } spin_opt = old_spin; beta = 1.0 / kT * prefac; minweight = 0.0; weights[old_spin] = 0.0; - for (unsigned spin = 1; spin <= q; spin++) { // all possible new spins + for (igraph_integer_t spin = 1; spin <= q; spin++) { // all possible new spins if (spin != old_spin) { // except the old one! h = color_field[spin] - (color_field[old_spin] - delta); weights[spin] = neighbours[old_spin] - neighbours[spin] + gamma * prob * h; @@ -826,7 +704,7 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned } } } // for spin - for (unsigned spin = 1; spin <= q; spin++) { // all possible new spins + for (igraph_integer_t spin = 1; spin <= q; spin++) { // all possible new spins weights[spin] -= minweight; // subtract minweigt // for numerical stability weights[spin] = exp(-beta * weights[spin]); @@ -835,26 +713,17 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned //choose a new spin - /* r = norm*double(rand())/double(RAND_MAX + 1.0); */ r = RNG_UNIF(0, norm); new_spin = 1; - //found = false; - while (/*!found &&*/ new_spin <= q) { + while (new_spin <= q) { if (r <= weights[new_spin]) { spin_opt = new_spin; - //found = true; break; } else { r -= weights[new_spin]; } new_spin++; } - /* - if (!found) { - printf("."); - problemcount++; - } - */ //------------------------------- //now set the new spin new_spin = spin_opt; @@ -887,8 +756,8 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned } // while markov max_q = 0; - for (unsigned long i = 1; i <= q; i++) if (color_field[i] > max_q) { - max_q = long(color_field[i] + 0.5); + for (igraph_integer_t i = 1; i <= q; i++) if (color_field[i] > max_q) { + max_q = igraph_integer_t(color_field[i] + 0.5); } acceptance = double(changes) / double(number_of_nodes) / double(sweep); @@ -898,38 +767,33 @@ double PottsModel::HeatBathLookup(double gamma, double prob, double kT, unsigned //############################################################################################### //# Here we try to minimize the affinity to the rest of the network //############################################################################################### -double PottsModel::FindCommunityFromStart(double gamma, double prob, - char *nodename, +double PottsModel::FindCommunityFromStart( + double gamma, + const char *nodename, igraph_vector_int_t *result, igraph_real_t *cohesion, igraph_real_t *adhesion, igraph_integer_t *my_inner_links, - igraph_integer_t *my_outer_links) { + igraph_integer_t *my_outer_links) const { DLList_Iter iter, iter2; DLList_Iter l_iter; - DLList* to_do; - DLList* community; - NNode *start_node = NULL, *n_cur, *neighbor, *max_aff_node, *node; + DLList to_do; + DLList community; + NNode *start_node = nullptr, *n_cur, *neighbor, *max_aff_node, *node; NLink *l_cur; bool found = false, add = false, remove = false; double degree, delta_aff_add, delta_aff_rem, max_delta_aff, Ks = 0.0, Kr = 0, kis, kir, w; - long community_marker = 5; - long to_do_marker = 10; + igraph_integer_t community_marker = 5; + igraph_integer_t to_do_marker = 10; double inner_links = 0, outer_links = 0, aff_r, aff_s; - IGRAPH_UNUSED(prob); - - to_do = new DLList; - community = new DLList; - // find the node in the network - n_cur = iter.First(net->node_list); + n_cur = iter.First(&net->node_list); while (!found && !iter.End()) { if (0 == strcmp(n_cur->Get_Name(), nodename)) { start_node = n_cur; found = true; - start_node->Set_Affinity(0.0); - community->Push(start_node); + community.Push(start_node); start_node->Set_Marker(community_marker); Ks = start_node->Get_Weight(); Kr = total_degree_sum - start_node->Get_Weight(); @@ -937,10 +801,6 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, n_cur = iter.Next(); } if (!found) { -// printf("%s not found found. Aborting.\n",nodename); -// fprintf(file,"%s not found found. Aborting.\n",nodename); - delete to_do; - delete community; return -1; } //############################# @@ -948,22 +808,20 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, //############################# neighbor = iter.First(start_node->Get_Neighbours()); while (!iter.End()) { -// printf("Adding node %s to comunity.\n",neighbor->Get_Name()); - community->Push(neighbor); + community.Push(neighbor); neighbor->Set_Marker(community_marker); Ks += neighbor->Get_Weight(); Kr -= neighbor->Get_Weight(); neighbor = iter.Next(); } - node = iter.First(community); + node = iter.First(&community); while (!iter.End()) { //now add at the second neighbors to the to_do list neighbor = iter2.First(node->Get_Neighbours()); while (!iter2.End()) { - if ((long)neighbor->Get_Marker() != community_marker && (long)neighbor->Get_Marker() != to_do_marker) { - to_do->Push(neighbor); + if (neighbor->Get_Marker() != community_marker && neighbor->Get_Marker() != to_do_marker) { + to_do.Push(neighbor); neighbor->Set_Marker(to_do_marker); -// printf("Adding node %s to to_do list.\n",neighbor->Get_Name()); } neighbor = iter2.Next(); } @@ -983,9 +841,9 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, IGRAPH_ALLOW_INTERRUPTION(); /* This is not clean.... */ max_delta_aff = 0.0; - max_aff_node = NULL; + max_aff_node = nullptr; add = false; - node = iter.First(to_do); + node = iter.First(&to_do); while (!iter.End()) { //printf("Checking Links of %s\n",node->Get_Name()); degree = node->Get_Weight(); @@ -1000,7 +858,7 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, } else { n_cur = l_cur->Get_Start(); } - if ((long)n_cur->Get_Marker() == community_marker) { + if (n_cur->Get_Marker() == community_marker) { kis += w; //the weight/number of links to the community } else { kir += w; //the weight/number of links to the rest of the network @@ -1010,14 +868,11 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, aff_r = kir - gamma / total_degree_sum * (Kr - degree) * degree; aff_s = kis - gamma / total_degree_sum * Ks * degree; delta_aff_add = aff_r - aff_s; - // if (aff_s>=aff_r && delta_aff_add<=max_delta_aff) { if (delta_aff_add <= max_delta_aff) { - node->Set_Affinity(aff_s); max_delta_aff = delta_aff_add; max_aff_node = node; add = true; } - //printf("%s in to_do list with affinity %f\n",node->Get_Name(),node->Get_Affinity()); node = iter.Next(); } //################ @@ -1026,7 +881,7 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, inner_links = 0; outer_links = 0; remove = false; - node = iter.First(community); + node = iter.First(&community); while (!iter.End()) { //printf("Checking Links of %s\n",node->Get_Name()); degree = node->Get_Weight(); @@ -1041,7 +896,7 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, } else { n_cur = l_cur->Get_Start(); } - if ((long)n_cur->Get_Marker() == community_marker) { + if (n_cur->Get_Marker() == community_marker) { kis += w; inner_links += w; //summing all w gives twice the number of inner links(weights) } else { @@ -1050,11 +905,9 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, } l_cur = l_iter.Next(); } -// if (kir+kis!=degree) { printf("error kir=%f\tkis=%f\tk=%f\n",kir,kis,degree); } aff_r = kir - gamma / total_degree_sum * Kr * degree; aff_s = kis - gamma / total_degree_sum * (Ks - degree) * degree; delta_aff_rem = aff_s - aff_r; - node->Set_Affinity(aff_s); // we should not remove the nodes, we have just added if (delta_aff_rem < max_delta_aff) { max_delta_aff = delta_aff_rem ; @@ -1062,7 +915,6 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, remove = true; add = false; } - //printf("%s in to_do list with affinity %f\n",node->Get_Name(),node->Get_Affinity()); node = iter.Next(); } inner_links = inner_links * 0.5; @@ -1073,20 +925,19 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, //################ //add the node of maximum affinity to the community //############### - community->Push(max_aff_node); + community.Push(max_aff_node); max_aff_node->Set_Marker(community_marker); //delete node from to_do - to_do->fDelete(max_aff_node); + to_do.fDelete(max_aff_node); //update the sum of degrees in the community Ks += max_aff_node->Get_Weight(); Kr -= max_aff_node->Get_Weight(); -// printf("Adding node %s to community with affinity of %f delta_aff: %f.\n",max_aff_node->Get_Name(), max_aff_node->Get_Affinity(),max_delta_aff); //now add all neighbors of this node, that are not already //in the to_do list or in the community neighbor = iter.First(max_aff_node->Get_Neighbours()); while (!iter.End()) { - if ((long)neighbor->Get_Marker() != community_marker && (long)neighbor->Get_Marker() != to_do_marker) { - to_do->Push(neighbor); + if (neighbor->Get_Marker() != community_marker && neighbor->Get_Marker() != to_do_marker) { + to_do.Push(neighbor); neighbor->Set_Marker(to_do_marker); //printf("Adding node %s to to_do list.\n",neighbor->Get_Name()); } @@ -1097,27 +948,19 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, //################ //remove those with negative affinities //################ - community->fDelete(max_aff_node); + community.fDelete(max_aff_node); max_aff_node->Set_Marker(to_do_marker); //update the sum of degrees in the community Ks -= max_aff_node->Get_Weight(); Kr += max_aff_node->Get_Weight(); //add the node to to_do again - to_do->Push(max_aff_node); -// printf("Removing node %s from community with affinity of %f delta_aff: %f.\n",max_aff_node->Get_Name(), max_aff_node->Get_Affinity(),max_delta_aff); + to_do.Push(max_aff_node); } IGRAPH_ALLOW_INTERRUPTION(); /* This is not clean.... */ } //################### //write the node in the community to a file //################### - // TODO return this instead of writing it -// fprintf(file,"Number_of_nodes:\t%d\n",community->Size()); -// fprintf(file,"Inner_Links:\t%f\n",inner_links); -// fprintf(file,"Outer_Links:\t%f\n",Ks-2*inner_links); -// fprintf(file,"Cohesion:\t%f\n",inner_links-gamma/total_degree_sum*Ks*Ks*0.5); -// fprintf(file,"Adhesion:\t%f\n",outer_links-gamma/total_degree_sum*Ks*Kr); -// fprintf(file,"\n"); if (cohesion) { *cohesion = inner_links - gamma / total_degree_sum * Ks * Ks * 0.5; } @@ -1131,62 +974,42 @@ double PottsModel::FindCommunityFromStart(double gamma, double prob, *my_outer_links = outer_links; } if (result) { - node = iter.First(community); + node = iter.First(&community); igraph_vector_int_clear(result); while (!iter.End()) { - // printf("%s in community.\n",node->Get_Name()); - // fprintf(file,"%s\t%f\n",node->Get_Name(),node->Get_Affinity()); IGRAPH_CHECK(igraph_vector_int_push_back(result, node->Get_Index())); node = iter.Next(); } } -// printf("%d nodes in community around %s\n",community->Size(),start_node->Get_Name()); -// fclose(file); - unsigned long size = community->Size(); - delete to_do; - delete community; + igraph_integer_t size = community.Size(); return size; } //################################################################################################ // this Function writes the clusters to disk //################################################################################################ -long PottsModel::WriteClusters(igraph_real_t *modularity, +igraph_integer_t PottsModel::WriteClusters(igraph_real_t *modularity, igraph_real_t *temperature, igraph_vector_int_t *csize, igraph_vector_int_t *membership, - double kT, double gamma) { - NNode *n_cur, *n_cur2; - /* - double a1,a2,a3,p,p1,p2; - long n,N,lin,lout; - */ + double kT, double gamma) const { + const NNode *n_cur, *n_cur2; DLList_Iter iter, iter2; HugeArray inner_links; HugeArray outer_links; HugeArray nodes; - //den Header schreiben -// p=2.0*double(num_of_links)/double(num_of_nodes)/double(num_of_nodes-1); -// fprintf(file," Nodes=\t%lu\n",num_of_nodes); -// fprintf(file," Links=\t%lu\n",num_of_links); -// fprintf(file," q=\t%d\n",q); -// fprintf(file," p=\t%f\n",p); -// fprintf(file," Modularity=\t%f\n",calculate_Q()); -// fprintf(file,"Temperature=\t%f\n", kT); -// fprintf(file,"Cluster\tNodes\tInnerLinks\tOuterLinks\tp_in\tp_out\t\n"); - if (temperature) { *temperature = kT; } if (csize || membership || modularity) { // TODO: count the number of clusters - for (unsigned long spin = 1; spin <= q; spin++) { + for (igraph_integer_t spin = 1; spin <= q; spin++) { inner_links[spin] = 0; outer_links[spin] = 0; nodes[spin] = 0; - n_cur = iter.First(net->node_list); + n_cur = iter.First(&net->node_list); while (!iter.End()) { if (n_cur->Get_ClusterIndex() == spin) { nodes[spin]++; @@ -1206,7 +1029,7 @@ long PottsModel::WriteClusters(igraph_real_t *modularity, } if (modularity) { *modularity = 0.0; - for (unsigned long spin = 1; spin <= q; spin++) { + for (igraph_integer_t spin = 1; spin <= q; spin++) { if (nodes[spin] > 0) { double t1 = inner_links[spin] / net->sum_weights / 2.0; double t2 = (inner_links[spin] + outer_links[spin]) / @@ -1218,52 +1041,25 @@ long PottsModel::WriteClusters(igraph_real_t *modularity, } if (csize) { igraph_vector_int_clear(csize); - for (unsigned long spin = 1; spin <= q; spin++) { + for (igraph_integer_t spin = 1; spin <= q; spin++) { if (nodes[spin] > 0) { inner_links[spin] /= 2; - // fprintf(file,"Cluster\tNodes\tInnerLinks\tOuterLinks\tp_in\tp_out\n"); - /* - N=num_of_nodes; - n=nodes[spin]; - lin=inner_links[spin]; - lout=outer_links[spin]; - a1=N*log((double)N)-n*log((double)n)*(N-n)*log((double)N-n); - if ((lin==long(n*(n-1)*0.5+0.5)) || (n==1)) a2=0.0; - else a2=(n*(n-1)*0.5 )*log((double)n*(n-1)*0.5 )-(n*(n-1)*0.5 )- - (n*(n-1)*0.5-lin)*log((double)n*(n-1)*0.5-lin)+(n*(n-1)*0.5-lin)- - lin*log((double)lin )+lin; - */ - - /* - if ((lout==n*(N-n)) || n==N) a3=0.0; - else a3=(n*(N-n) )*log((double)n*(N-n) )-(n*(N-n))- - (n*(N-n)-lout)*log((double)n*(N-n)-lout)+(n*(N-n)-lout)- - lout*log((double)lout )+lout; - */ - - /* - p1=(lin+lout)*log((double)p); - p2=(0.5*n*(n-1)-lin + n*(N-n)-lout)*log((double)1.0-p); - */ - // fprintf(file,"%d\t%d\t%d\t%d\t%f\t%f\t%f\n",spin,nodes[spin], inner_links[spin], outer_links[spin], p_in, p_out,log_num_exp); IGRAPH_CHECK(igraph_vector_int_push_back(csize, nodes[spin])); } } - // fprintf(file,"\n"); } //die Elemente der Cluster if (membership) { igraph_integer_t no = -1; IGRAPH_CHECK(igraph_vector_int_resize(membership, num_of_nodes)); - for (unsigned long spin = 1; spin <= q; spin++) { + for (igraph_integer_t spin = 1; spin <= q; spin++) { if (nodes[spin] > 0) { no++; } - n_cur = iter.First(net->node_list); + n_cur = iter.First(&net->node_list); while (!iter.End()) { if (n_cur->Get_ClusterIndex() == spin) { - // fprintf(file,"%d\t%s\n",spin,n_cur->Get_Name()); VECTOR(*membership)[ n_cur->Get_Index() ] = no; } n_cur = iter.Next(); @@ -1273,303 +1069,11 @@ long PottsModel::WriteClusters(igraph_real_t *modularity, return num_of_nodes; } -//################################################################################################ -//This function writes the soft clusters after a gamma sweep -//that is, it groups every node together that was found in -// more than threshold percent together with the other node -// in the same cluster -//################################################################################################ -// Does not work at the moment !!! -//################################################################################################ -// long PottsModel::WriteSoftClusters(char *filename, double threshold) -// { -// FILE *file; -// NNode *n_cur, *n_cur2; -// DLList_Iter iter, iter2; -// DL_Indexed_List*> *cl_list, *old_clusterlist; -// ClusterList *cl_cur; - -// double max; - -// file=fopen(filename,"w"); -// if (!file) { -// printf("Could not open %s for writing.\n",filename); -// return -1; -// } - -// max=correlation[0]->Get(0); -// //printf("max=%f\n",max); -// cl_list=new DL_Indexed_List*>(); - -// n_cur=iter.First(net->node_list); -// while (!iter.End()) -// { -// cl_cur=new ClusterList(); -// cl_list->Push(cl_cur); -// n_cur2=iter2.First(net->node_list); -// while (!iter2.End()) -// { -// if (double(correlation[n_cur->Get_Index()]->Get(n_cur2->Get_Index()))/max>threshold) -// cl_cur->Push(n_cur2); -// n_cur2=iter2.Next(); -// } -// n_cur=iter.Next(); -// } -// old_clusterlist=net->cluster_list; -// net->cluster_list=cl_list; -// clear_all_markers(net); -// //printf("Es gibt %d Cluster\n",cl_list->Size()); -// reduce_cliques2(net, false, 15); -// //printf("Davon bleiben %d Cluster uebrig\n",cl_list->Size()); -// clear_all_markers(net); -// while (net->cluster_list->Size()){ -// cl_cur=net->cluster_list->Pop(); -// while (cl_cur->Size()) -// { -// n_cur=cl_cur->Pop(); -// fprintf(file,"%s\n",n_cur->Get_Name()); -// //printf("%s\n",n_cur->Get_Name()); -// } -// fprintf(file,"\n"); -// } -// net->cluster_list=old_clusterlist; -// fclose(file); - -// return 1; -// } -//############################################################################# -// Performs a gamma sweep -//############################################################################# -double PottsModel::GammaSweep(double gamma_start, double gamma_stop, double prob, unsigned int steps, bool non_parallel, int repetitions) { - double stepsize; - double kT = 0.5, kT_start; - long changes; - double gamma, acc; - NNode *n_cur, *n_cur2; - DLList_Iter iter, iter2; - - stepsize = (gamma_stop - gamma_start) / double(steps); - - n_cur = iter.First(net->node_list); - while (!iter.End()) { - correlation[n_cur->Get_Index()] = new HugeArray(); - n_cur2 = iter2.First(net->node_list); - while (!iter2.End()) { - correlation[n_cur->Get_Index()]->Set(n_cur->Get_Index()) = 0.0; - n_cur2 = iter2.Next(); - } - n_cur = iter.Next(); - } - - for (unsigned int n = 0; n <= steps; n++) { - assign_initial_conf(-1); - initialize_Qmatrix(); - gamma = gamma_start + stepsize * n; - kT = 0.5; - acceptance = 0.5; - while (acceptance < (1.0 - 1.0 / double(q)) * 0.95) { //wollen 95% Acceptance - kT *= 1.1; - //initialize_lookup(kT,kmax,net->node_list->Size()); - if (!non_parallel) { - HeatBathParallelLookup(gamma, prob, kT, 25); - } else { - HeatBathLookup(gamma, prob, kT, 25); - } - // printf("kT=%f acceptance=%f\n", kT, acceptance); - } - // printf("Starting with gamma=%f\n", gamma); - kT_start = kT; - - for (int i = 0; i < repetitions; i++) { - changes = 1; - kT = kT_start; - assign_initial_conf(-1); - initialize_Qmatrix(); - while ((changes > 0) && (kT > 0.01)) { - kT = kT * 0.99; - //initialize_lookup(kT,kmax,net->node_list->Size()); - if (!non_parallel) { - changes = HeatBathParallelLookup(gamma, prob, kT, 50); - // printf("kT: %f \t Changes %li\n",kT, changes); - } else { - acc = HeatBathLookup(gamma, prob, kT, 50); - if (acc > (1.0 - 1.0 / double(q)) * 0.01) { - changes = 1; - } else { - changes = 0; - } - // printf("kT: %f Acceptance: %f\n",kT, acc); - } - } - // printf("Finisched with acceptance: %1.6f bei kT=%2.4f und gamma=%2.4f\n",acceptance,kT, gamma); -// fprintf(file,"%f\t%f\n",gamma_,acceptance); -// fprintf(file2,"%f\t%f\n",gamma_,kT); - // fprintf(file3,"%f\t%d\n",gamma_,count_clusters(5)); - - //Die Correlation berechnen - n_cur = iter.First(net->node_list); - while (!iter.End()) { - n_cur2 = iter2.First(net->node_list); - while (!iter2.End()) { - if (n_cur->Get_ClusterIndex() == n_cur2->Get_ClusterIndex()) { - correlation[n_cur->Get_Index()]->Set(n_cur2->Get_Index()) += 0.5; - } - n_cur2 = iter2.Next(); - } - n_cur = iter.Next(); - } - } // for i - } //for n - return kT; -} -//############################################################################# -//Performs a Gamma sweep at zero T -//############################################################################# -double PottsModel::GammaSweepZeroTemp(double gamma_start, double gamma_stop, double prob, unsigned int steps, bool non_parallel, int repetitions) { - double stepsize; - long changes; - double gamma = gamma_start, acc; - long runs; - NNode *n_cur, *n_cur2; - DLList_Iter iter, iter2; - - stepsize = (gamma_stop - gamma_start) / double(steps); - - n_cur = iter.First(net->node_list); - while (!iter.End()) { - correlation[n_cur->Get_Index()] = new HugeArray(); - n_cur2 = iter2.First(net->node_list); - while (!iter2.End()) { - correlation[n_cur->Get_Index()]->Set(n_cur->Get_Index()) = 0.0; - n_cur2 = iter2.Next(); - } - n_cur = iter.Next(); - } - - for (unsigned int n = 0; n <= steps; n++) { - assign_initial_conf(-1); - initialize_Qmatrix(); - gamma = gamma_start + stepsize * n; - // printf("Starting with gamma=%f\n", gamma); - for (int i = 0; i < repetitions; i++) { - changes = 1; - assign_initial_conf(-1); - initialize_Qmatrix(); - runs = 0; - while (changes > 0 && runs < 250) { - //initialize_lookup(kT,kmax,net->node_list->Size()); - if (!non_parallel) { - changes = HeatBathParallelLookupZeroTemp(gamma, prob, 1); - // printf("Changes %li\n", changes); - } else { - acc = HeatBathLookupZeroTemp(gamma, prob, 1); - if (acc > (1.0 - 1.0 / double(q)) * 0.01) { - changes = 1; - } else { - changes = 0; - } - // printf("Acceptance: %f\n", acc); - } - runs++; - } - // printf("Finisched with Modularity: %1.6f bei Gamma=%1.6f\n",calculate_Q(), gamma); -// fprintf(file,"%f\t%f\n",gamma_,acceptance); -// fprintf(file2,"%f\t%f\n",gamma_,kT); - // fprintf(file3,"%f\t%d\n",gamma_,count_clusters(5)); - - //Die Correlation berechnen - n_cur = iter.First(net->node_list); - while (!iter.End()) { - n_cur2 = iter2.First(net->node_list); - while (!iter2.End()) { - if (n_cur->Get_ClusterIndex() == n_cur2->Get_ClusterIndex()) { - correlation[n_cur->Get_Index()]->Set(n_cur2->Get_Index()) += 0.5; - correlation[n_cur2->Get_Index()]->Set(n_cur->Get_Index()) += 0.5; - } - n_cur2 = iter2.Next(); - } - n_cur = iter.Next(); - } - } // for i - } //for n - return gamma; -} -//####################################################################### -//----------------------------------------------------------------------- -//####################################################################### -// This function writes the Correlation Matrix that results from a -// Gamma-Sweep, this matrix is used to make ps files of it. -// ###################################################################### -// long PottsModel::WriteCorrelationMatrix(char *filename) -// { -// FILE *file, *file2; -// char filename2[255]; -// NNode *n_cur, *n_cur2; -// DLList_Iter iter, iter2; - -// sprintf(filename2,"%s.mat",filename); -// file=fopen(filename,"w"); -// if (!file) { -// printf("Could not open %s for writing.\n",filename); -// return -1; -// } -// file2=fopen(filename2,"w"); -// if (!file2) { -// printf("Could not open %s for writing.\n",filename2); -// return -1; -// } -// //write the header in one line -// n_cur=iter.First(net->node_list); -// while (!iter.End()) -// { -// fprintf(file, "\t%s",n_cur->Get_Name()); -// n_cur=iter.Next(); -// } -// fprintf(file, "\n"); - -// //fprintf(file, "%d\t%d\n",net->node_list->Size(),net->node_list->Size()); - -// long r=0,c=0; -// n_cur=iter.First(net->node_list); -// while (!iter.End()) -// { -// fprintf(file, "%s",n_cur->Get_Name()); -// r++; -// n_cur2=iter2.First(net->node_list); -// while (!iter2.End()) -// { -// c++; -// fprintf(file,"\t%f",correlation[n_cur->Get_Index()]->Get(n_cur2->Get_Index())); -// fprintf(file2,"%li\t%li\t%f\n",r,c,correlation[n_cur->Get_Index()]->Get(n_cur2->Get_Index())); -// n_cur2=iter2.Next(); -// } -// fprintf(file,"\n"); -// n_cur=iter.Next(); -// } -// fclose(file); -// fclose(file2); -// return 1; -// } -//############################################################################## //################################################################################################# -PottsModelN::PottsModelN(network *n, unsigned long num_communities, bool directed) : - degree_pos_in(NULL), degree_neg_in(NULL), - degree_pos_out(NULL), degree_neg_out(NULL), - degree_community_pos_in(NULL), degree_community_neg_in(NULL), - degree_community_pos_out(NULL), degree_community_neg_out(NULL), - csize(NULL), spin(NULL), neighbours(NULL), weights(NULL) -{ - //Set internal variable - net = n; - q = num_communities; - - is_directed = directed; - - is_init = false; - - num_nodes = net->node_list->Size(); -} +PottsModelN::PottsModelN(network *n, igraph_integer_t num_communities, bool directed) : + net(n), q(num_communities), num_nodes(net->node_list.Size()), is_directed(directed) +{ } //####################################################### //Destructor of PottsModel //######################################################## @@ -1592,20 +1096,12 @@ PottsModelN::~PottsModelN() { } void PottsModelN::assign_initial_conf(bool init_spins) { -#ifdef SPINGLASS_DEBUG - printf("Start assigning.\n"); -#endif - unsigned long s; - DLList_Iter iter; + igraph_integer_t s; DLList_Iter l_iter; - NNode *n_cur; - NLink *l_cur; - + const NNode *n_cur; + const NLink *l_cur; if (init_spins) { -#ifdef SPINGLASS_DEBUG - printf("Initializing spin.\n"); -#endif // Free the arrays before (re-)allocating them // These arrays are initialized to NULL, so it is safe to delete even before allocation delete [] degree_pos_in; @@ -1621,7 +1117,7 @@ void PottsModelN::assign_initial_conf(bool init_spins) { degree_pos_out = new double[num_nodes]; //Postive outdegree of the nodes (or sum of weights) degree_neg_out = new double[num_nodes]; //Negative outdegree of the nodes (or sum of weights) - spin = new unsigned long[num_nodes]; //The spin state of each node + spin = new igraph_integer_t[num_nodes]; //The spin state of each node } if (is_init) { @@ -1646,11 +1142,11 @@ void PottsModelN::assign_initial_conf(bool init_spins) { //...and of weights and neighbours for in the HeathBathLookup weights = new double[q + 1]; //The weights for changing to another spin state neighbours = new double[q + 1]; //The number of neighbours (or weights) in different spin states - csize = new unsigned long[q + 1]; //The number of nodes in each community + csize = new igraph_integer_t[q + 1]; //The number of nodes in each community //Initialize communities - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { degree_community_pos_in[i] = 0.0; degree_community_neg_in[i] = 0.0; degree_community_pos_out[i] = 0.0; @@ -1661,7 +1157,7 @@ void PottsModelN::assign_initial_conf(bool init_spins) { //Initialize vectors if (init_spins) { - for (unsigned long i = 0; i < num_nodes; i++) { + for (igraph_integer_t i = 0; i < num_nodes; i++) { degree_pos_in[i] = 0.0; degree_neg_in[i] = 0.0; degree_pos_out[i] = 0.0; @@ -1679,15 +1175,11 @@ void PottsModelN::assign_initial_conf(bool init_spins) { //correctly store it in the bookkeeping double sum_weight_pos_in, sum_weight_pos_out, sum_weight_neg_in, sum_weight_neg_out; - //double av_w = 0.0, av_k=0.0; - //int l = 0; -#ifdef SPINGLASS_DEBUG - printf("Visiting each node.\n"); -#endif - for (unsigned long v = 0; v < num_nodes; v++) { + + for (igraph_integer_t v = 0; v < num_nodes; v++) { if (init_spins) { s = RNG_INTEGER(1, q); //The new spin s - spin[v] = (unsigned int)s; + spin[v] = s; } else { s = spin[v]; } @@ -1696,7 +1188,7 @@ void PottsModelN::assign_initial_conf(bool init_spins) { printf("Spin %d assigned to node %d.\n", s, v); #endif - n_cur = net->node_list->Get(v); + n_cur = net->node_list.Get(v); l_cur = l_iter.First(n_cur->Get_Links()); @@ -1707,8 +1199,6 @@ void PottsModelN::assign_initial_conf(bool init_spins) { while (!l_iter.End()) { double w = l_cur->Get_Weight(); - //av_w = (av_w*l + w)/(l+1); //Average weight - //l++; if (l_cur->Get_Start() == n_cur) //From this to other, so outgoing link if (w > 0) { sum_weight_pos_out += w; //Increase positive outgoing weight @@ -1732,8 +1222,6 @@ void PottsModelN::assign_initial_conf(bool init_spins) { sum_weight_neg_in = sum_weight_neg; } - //av_k = (av_k*l + sum_weight_pos_in)/(l+1); //Average k - if (init_spins) { //Set the degrees correctly degree_pos_in[v] = sum_weight_pos_in; @@ -1768,23 +1256,21 @@ double PottsModelN::HeatBathLookup(double gamma, double lambda, double t, unsign #ifdef SPINGLASS_DEBUG printf("Starting sweep at temperature %f.\n", t); #endif - DLList_Iter iter; DLList_Iter l_iter; - DLList_Iter i_iter, i_iter2; - NNode *node, *n_cur; - NLink *l_cur; + const NNode *node, *n_cur; + const NLink *l_cur; /* The new_spin contains the spin to which we will update, * the spin_opt is the optional spin we will consider and * the old_spin is the spin of the node we are currently * changing. */ - unsigned long new_spin, spin_opt, old_spin; + igraph_integer_t new_spin, spin_opt, old_spin; unsigned int sweep; //current sweep - unsigned long changes/*, problemcount*/; //Number of changes and number of problems encountered + igraph_integer_t changes/*, problemcount*/; //Number of changes and number of problems encountered double exp_old_spin; //The expectation value for the old spin double exp_spin; //The expectation value for the other spin(s) - long v; //The node we will be investigating + igraph_integer_t v; //The node we will be investigating //The variables required for the calculations double delta_pos_out, delta_pos_in, delta_neg_out, delta_neg_in; @@ -1793,7 +1279,7 @@ double PottsModelN::HeatBathLookup(double gamma, double lambda, double t, unsign //weight of edge double w; - double beta = 1 / t; //Weight for probabilities + double beta = 1.0 / t; //Weight for probabilities double r = 0.0; //random number used for assigning new spin double maxweight = 0.0; @@ -1815,17 +1301,17 @@ double PottsModelN::HeatBathLookup(double gamma, double lambda, double t, unsign while (sweep < max_sweeps) { sweep++; //loop over all nodes in network - for (unsigned long n = 0; n < num_nodes; n++) { + for (igraph_integer_t n = 0; n < num_nodes; n++) { //Look for a random node v = RNG_INTEGER(0, num_nodes - 1); //We will be investigating node v - node = net->node_list->Get(v); + node = net->node_list.Get(v); /*******************************************/ // initialize the neighbours and the weights // problemcount = 0; - for (unsigned long i = 0; i <= q; i++) { + for (igraph_integer_t i = 0; i <= q; i++) { neighbours[i] = 0.0; weights[i] = 0.0; } @@ -1899,7 +1385,7 @@ double PottsModelN::HeatBathLookup(double gamma, double lambda, double t, unsign sum_weights = 0.0; for (spin_opt = 1; spin_opt <= q; spin_opt++) { // all possible new spins weights[spin_opt] -= maxweight; //subtract maxweight for numerical stability (otherwise overflow). - weights[spin_opt] = exp((double)(beta * weights[spin_opt])); + weights[spin_opt] = exp(beta * weights[spin_opt]); sum_weights += weights[spin_opt]; } // for spin /*******************************************/ @@ -1910,11 +1396,9 @@ double PottsModelN::HeatBathLookup(double gamma, double lambda, double t, unsign r = RNG_UNIF(0, sum_weights); new_spin = 1; - bool found = false; - while (!found && new_spin <= q) { + while (new_spin <= q) { if (r <= weights[new_spin]) { spin_opt = new_spin; //We have found are new spin - found = true; break; } else { r -= weights[new_spin]; //Perhaps the next spin is the one we want @@ -1923,14 +1407,6 @@ double PottsModelN::HeatBathLookup(double gamma, double lambda, double t, unsign new_spin++; } - //Some weird thing happened. We haven't found a new spin - //while that shouldn't be the case. Numerical problems? - /* - if (!found) { - problemcount++; - } - */ - new_spin = spin_opt; //If there wasn't a problem we should have found //our new spin. @@ -1993,7 +1469,7 @@ double PottsModelN::FindStartTemp(double gamma, double lambda, double ts) { return kT; } -long PottsModelN::WriteClusters(igraph_real_t *modularity, +igraph_integer_t PottsModelN::WriteClusters(igraph_real_t *modularity, igraph_real_t *temperature, igraph_vector_int_t *community_size, igraph_vector_int_t *membership, @@ -2002,25 +1478,22 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, igraph_real_t *polarization, double t, double d_p, - double d_n, - double gamma, - double lambda) { - IGRAPH_UNUSED(gamma); - IGRAPH_UNUSED(lambda); + double d_n) { + #ifdef SPINGLASS_DEBUG printf("Start writing clusters.\n"); #endif //Reassign each community so that we retrieve a community assignment 1 through num_communities - unsigned long *cluster_assign = new unsigned long[q + 1]; - for (unsigned long i = 0; i <= q; i++) { + auto *cluster_assign = new igraph_integer_t[q + 1]; + for (igraph_integer_t i = 0; i <= q; i++) { cluster_assign[i] = 0; } - long num_clusters = 0; + igraph_integer_t num_clusters = 0; //Find out what the new communities will be - for (unsigned long i = 0; i < num_nodes; i++) { - unsigned long s = spin[i]; + for (igraph_integer_t i = 0; i < num_nodes; i++) { + igraph_integer_t s = spin[i]; if (cluster_assign[s] == 0) { num_clusters++; cluster_assign[s] = num_clusters; @@ -2030,20 +1503,13 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, } } - - /* - DLList_Iter iter; - NNode *n_cur=iter.First(net->node_list); - n_cur = iter.First(net->node_list); - */ - //And now assign each node to its new community q = num_clusters; - for (unsigned long i = 0; i < num_nodes; i++) { + for (igraph_integer_t i = 0; i < num_nodes; i++) { #ifdef SPINGLASS_DEBUG printf("Setting node %d to %d.\n", i, cluster_assign[spin[i]]); #endif - unsigned long s = cluster_assign[spin[i]]; + igraph_integer_t s = cluster_assign[spin[i]]; spin[i] = s; #ifdef SPINGLASS_DEBUG printf("Have set node %d to %d.\n", i, s); @@ -2051,7 +1517,7 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, } assign_initial_conf(false); - delete[] cluster_assign; + delete [] cluster_assign; if (temperature) { *temperature = t; @@ -2060,7 +1526,7 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, if (community_size) { //Initialize the vector IGRAPH_CHECK(igraph_vector_int_resize(community_size, q)); - for (unsigned long spin_opt = 1; spin_opt <= q; spin_opt++) { + for (igraph_integer_t spin_opt = 1; spin_opt <= q; spin_opt++) { //Set the community size VECTOR(*community_size)[spin_opt - 1] = csize[spin_opt]; } @@ -2069,7 +1535,7 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, //Set the membership if (membership) { IGRAPH_CHECK(igraph_vector_int_resize(membership, num_nodes)); - for (unsigned long i = 0; i < num_nodes; i++) { + for (igraph_integer_t i = 0; i < num_nodes; i++) { VECTOR(*membership)[ i ] = spin[i] - 1; } } @@ -2079,14 +1545,14 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, IGRAPH_CHECK(igraph_matrix_resize(adhesion, q, q)); IGRAPH_CHECK(igraph_matrix_resize(normalised_adhesion, q, q)); - double **num_links_pos = NULL; - double **num_links_neg = NULL; + double **num_links_pos = nullptr; + double **num_links_neg = nullptr; //memory allocated for elements of rows. num_links_pos = new double *[q + 1] ; num_links_neg = new double *[q + 1] ; //memory allocated for elements of each column. - for ( unsigned long i = 0 ; i < q + 1 ; i++) { + for ( igraph_integer_t i = 0 ; i < q + 1 ; i++) { num_links_pos[i] = new double[q + 1]; num_links_neg[i] = new double[q + 1]; } @@ -2094,22 +1560,22 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, //Init num_links - for (unsigned long i = 0; i <= q; i++) { - for (unsigned long j = 0; j <= q; j++) { + for (igraph_integer_t i = 0; i <= q; i++) { + for (igraph_integer_t j = 0; j <= q; j++) { num_links_pos[i][j] = 0.0; num_links_neg[i][j] = 0.0; } } DLList_Iter iter_l; - NLink *l_cur = iter_l.First(net->link_list); + const NLink *l_cur = iter_l.First(&net->link_list); double w = 0.0; while (!iter_l.End()) { w = l_cur->Get_Weight(); - unsigned long a = spin[l_cur->Get_Start()->Get_Index()]; - unsigned long b = spin[l_cur->Get_End()->Get_Index()]; + igraph_integer_t a = spin[l_cur->Get_Start()->Get_Index()]; + igraph_integer_t b = spin[l_cur->Get_End()->Get_Index()]; if (w > 0) { num_links_pos[a][b] += w; if (!is_directed && a != b) { //Only one edge is defined in case it is undirected @@ -2140,8 +1606,8 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, //We don't take into account the lambda or gamma for //computing the modularity and adhesion, since they //are then incomparable to other definitions. - for (unsigned long i = 1; i <= q; i++) { - for (unsigned long j = 1; j <= q; j++) { + for (igraph_integer_t i = 1; i <= q; i++) { + for (igraph_integer_t j = 1; j <= q; j++) { if (!is_directed && i == j) expected = degree_community_pos_out[i] * degree_community_pos_in[j] / (m_p == 0 ? 1 : 2 * m_p) - degree_community_neg_out[i] * degree_community_neg_in[j] / (m_n == 0 ? 1 : 2 * m_n); @@ -2178,8 +1644,6 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, else max_expected = (degree_community_pos_out[i] + u_p) * (degree_community_pos_in[j] + u_p) / ((m_p + u_p) == 0 ? 1 : m_p + u_p) - (degree_community_neg_out[i] - u_n) * (degree_community_neg_in[j] + u_n) / ((m_n + u_n) == 0 ? 1 : m_n + u_n); - //printf("%f/%f %d/%d\t", num_links_pos[i][j], num_links_neg[i][j], csize[i], csize[j]); - //printf("%f/%f - %f(%f)\t", u_p, u_n, expected, max_expected); max_a = ((num_links_pos[i][j] + u_p) - (num_links_neg[i][j] + u_n)) - max_expected; @@ -2208,7 +1672,7 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, } //for i //free the allocated memory - for ( unsigned long i = 0 ; i < q + 1 ; i++ ) { + for ( igraph_integer_t i = 0 ; i < q + 1 ; i++ ) { delete [] num_links_pos[i] ; delete [] num_links_neg[i]; } @@ -2227,8 +1691,8 @@ long PottsModelN::WriteClusters(igraph_real_t *modularity, if (polarization) { double sum_ad = 0.0; - for (unsigned long i = 0; i < q; i++) { - for (unsigned long j = 0; j < q; j++) { + for (igraph_integer_t i = 0; i < q; i++) { + for (igraph_integer_t j = 0; j < q; j++) { if (i != j) { sum_ad -= MATRIX(*normalised_adhesion, i, j); } diff --git a/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.h b/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.h index 27addecfedf..1cecba4268c 100644 --- a/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.h +++ b/src/vendor/cigraph/src/community/spinglass/pottsmodel_2.h @@ -54,10 +54,11 @@ // Simple matrix class with heap allocation, allowing mat[i][j] indexing. class SimpleMatrix { double *data; - size_t n; + const size_t n; public: explicit SimpleMatrix(size_t n_) : n(n_) { data = new double[n*n]; } + SimpleMatrix(const SimpleMatrix &) = delete; ~SimpleMatrix() { delete [] data; } // Return a pointer to the i'th column, which can be indexed into using a second [] operator. @@ -67,102 +68,89 @@ class SimpleMatrix { class PottsModel { private: - // HugeArray neg_gammalookup; - // HugeArray pos_gammalookup; - DL_Indexed_List *new_spins; - DL_Indexed_List *previous_spins; + //these lists are needed to keep track of spin states for parallel update mode + DL_Indexed_List new_spins; + DL_Indexed_List previous_spins; + HugeArray*> correlation; network *net; - unsigned long q; + igraph_integer_t q; unsigned int operation_mode; - // FILE *Qfile, *Magfile; SimpleMatrix Qmatrix; double* Qa; double* weights; double total_degree_sum; - unsigned long num_of_nodes; - unsigned long num_of_links; - unsigned long k_max; - double energy; - double acceptance; - double *neighbours; + igraph_integer_t num_of_nodes; + igraph_integer_t num_of_links; + igraph_integer_t k_max = 0; + double acceptance = 0; + double* neighbours; + double* color_field; public: - PottsModel(network *net, unsigned long q, int norm_by_degree); + PottsModel(network *net, igraph_integer_t q, int norm_by_degree); ~PottsModel(); - double* color_field; - unsigned long assign_initial_conf(igraph_integer_t spin); - unsigned long initialize_lookup(double kT, double gamma); + + igraph_integer_t assign_initial_conf(igraph_integer_t spin); + double initialize_Qmatrix(); double calculate_Q(); - double calculate_genQ(double gamma); + double FindStartTemp(double gamma, double prob, double ts); - long HeatBathParallelLookupZeroTemp(double gamma, double prob, unsigned int max_sweeps); + igraph_integer_t HeatBathParallelLookupZeroTemp(double gamma, double prob, unsigned int max_sweeps); double HeatBathLookupZeroTemp(double gamma, double prob, unsigned int max_sweeps); - long HeatBathParallelLookup(double gamma, double prob, double kT, unsigned int max_sweeps); + igraph_integer_t HeatBathParallelLookup(double gamma, double prob, double kT, unsigned int max_sweeps); double HeatBathLookup(double gamma, double prob, double kT, unsigned int max_sweeps); - double GammaSweep(double gamma_start, double gamma_stop, double prob, unsigned int steps, bool non_parallel = true, int repetitions = 1); - double GammaSweepZeroTemp(double gamma_start, double gamma_stop, double prob, unsigned int steps, bool non_parallel = true, int repetitions = 1); - // long WriteCorrelationMatrix(char *filename); - double calculate_energy(double gamma); - long WriteClusters(igraph_real_t *modularity, - igraph_real_t *temperature, - igraph_vector_int_t *csize, igraph_vector_int_t *membership, - double kT, double gamma); - // long WriteSoftClusters(char *filename, double threshold); - double Get_Energy() const { - return energy; - } - double FindCommunityFromStart(double gamma, double prob, char *nodename, + + igraph_integer_t WriteClusters(igraph_real_t *modularity, + igraph_real_t *temperature, + igraph_vector_int_t *csize, igraph_vector_int_t *membership, + double kT, double gamma) const; + + double FindCommunityFromStart(double gamma, const char *nodename, igraph_vector_int_t *result, igraph_real_t *cohesion, igraph_real_t *adhesion, igraph_integer_t *inner_links, - igraph_integer_t *outer_links); + igraph_integer_t *outer_links) const; }; class PottsModelN { private: - // HugeArray neg_gammalookup; - // HugeArray pos_gammalookup; - // DL_Indexed_List *new_spins; - // DL_Indexed_List *previous_spins; HugeArray*> correlation; network *net; - unsigned long q; //number of communities + igraph_integer_t q; //number of communities double m_p; //number of positive ties (or sum of degrees), this equals the number of edges only if it is undirected and each edge has a weight of 1 double m_n; //number of negative ties (or sum of degrees) - unsigned long num_nodes; //number of nodes + igraph_integer_t num_nodes; //number of nodes bool is_directed; - bool is_init; + bool is_init = false; - double *degree_pos_in; //Postive indegree of the nodes (or sum of weights) - double *degree_neg_in; //Negative indegree of the nodes (or sum of weights) - double *degree_pos_out; //Postive outdegree of the nodes (or sum of weights) - double *degree_neg_out; //Negative outdegree of the nodes (or sum of weights) + double *degree_pos_in = nullptr; //Postive indegree of the nodes (or sum of weights) + double *degree_neg_in = nullptr; //Negative indegree of the nodes (or sum of weights) + double *degree_pos_out = nullptr; //Postive outdegree of the nodes (or sum of weights) + double *degree_neg_out = nullptr; //Negative outdegree of the nodes (or sum of weights) - double *degree_community_pos_in; //Positive sum of indegree for communities - double *degree_community_neg_in; //Negative sum of indegree for communities - double *degree_community_pos_out; //Positive sum of outegree for communities - double *degree_community_neg_out; //Negative sum of outdegree for communities + double *degree_community_pos_in = nullptr; //Positive sum of indegree for communities + double *degree_community_neg_in = nullptr; //Negative sum of indegree for communities + double *degree_community_pos_out = nullptr; //Positive sum of outegree for communities + double *degree_community_neg_out = nullptr; //Negative sum of outdegree for communities - unsigned long *csize; //The number of nodes in each community - unsigned long *spin; //The membership of each node + igraph_integer_t *csize = nullptr; //The number of nodes in each community + igraph_integer_t *spin = nullptr; //The membership of each node - double *neighbours; //Array of neighbours of a vertex in each community - double *weights; //Weights of all possible transitions to another community + double *neighbours = nullptr; //Array of neighbours of a vertex in each community + double *weights = nullptr; //Weights of all possible transitions to another community public: - PottsModelN(network *n, unsigned long num_communities, bool directed); + PottsModelN(network *n, igraph_integer_t num_communities, bool directed); ~PottsModelN(); void assign_initial_conf(bool init_spins); double FindStartTemp(double gamma, double lambda, double ts); double HeatBathLookup(double gamma, double lambda, double t, unsigned int max_sweeps); - // double HeatBathJoin(double gamma, double lambda); - // double HeatBathLookupZeroTemp(double gamma, double lambda, unsigned int max_sweeps); - long WriteClusters(igraph_real_t *modularity, + igraph_integer_t WriteClusters(igraph_real_t *modularity, igraph_real_t *temperature, igraph_vector_int_t *community_size, igraph_vector_int_t *membership, @@ -171,9 +159,7 @@ class PottsModelN { igraph_real_t *polarization, double t, double d_p, - double d_n, - double gamma, - double lambda); + double d_n); }; #endif diff --git a/src/vendor/cigraph/src/connectivity/separators.c b/src/vendor/cigraph/src/connectivity/separators.c index 1bca02b68fb..1473acafdeb 100644 --- a/src/vendor/cigraph/src/connectivity/separators.c +++ b/src/vendor/cigraph/src/connectivity/separators.c @@ -553,7 +553,6 @@ static igraph_error_t igraph_i_minimum_size_separators_append( igraph_integer_t j; while (!igraph_vector_int_list_empty(new)) { - igraph_vector_int_t *oldvec; igraph_vector_int_t *newvec = igraph_vector_int_list_tail_ptr(new); /* Check whether the separator is already in `old' */ @@ -568,6 +567,7 @@ static igraph_error_t igraph_i_minimum_size_separators_append( /* We have found a new separator, append it to `old'. We do it by * extending it with an empty vector and then swapping it with * the new vector to be appended */ + igraph_vector_int_t *oldvec; IGRAPH_CHECK(igraph_vector_int_list_push_back_new(old, &oldvec)); igraph_vector_int_swap(oldvec, newvec); olen++; diff --git a/src/vendor/cigraph/src/constructors/atlas.c b/src/vendor/cigraph/src/constructors/atlas.c index 1ab4615cf1f..b901e94f661 100644 --- a/src/vendor/cigraph/src/constructors/atlas.c +++ b/src/vendor/cigraph/src/constructors/atlas.c @@ -61,21 +61,19 @@ */ igraph_error_t igraph_atlas(igraph_t *graph, igraph_integer_t number) { - igraph_integer_t pos, n, e; - igraph_vector_int_t v = IGRAPH_VECTOR_NULL; + const igraph_vector_int_t v; if (number < 0 || - number >= (int) (sizeof(igraph_i_atlas_edges_pos) / sizeof(igraph_i_atlas_edges_pos[0]))) { + number >= sizeof(igraph_i_atlas_edges_pos) / sizeof(igraph_i_atlas_edges_pos[0])) { IGRAPH_ERROR("No such graph in atlas", IGRAPH_EINVAL); } - pos = igraph_i_atlas_edges_pos[number]; - n = igraph_i_atlas_edges[pos]; - e = igraph_i_atlas_edges[pos + 1]; + igraph_integer_t pos = igraph_i_atlas_edges_pos[number]; + igraph_integer_t n = igraph_i_atlas_edges[pos]; + igraph_integer_t e = igraph_i_atlas_edges[pos + 1]; IGRAPH_CHECK(igraph_create(graph, - igraph_vector_int_view(&v, igraph_i_atlas_edges + pos + 2, - e * 2), + igraph_vector_int_view(&v, igraph_i_atlas_edges + pos + 2, e * 2), n, IGRAPH_UNDIRECTED)); return IGRAPH_SUCCESS; diff --git a/src/vendor/cigraph/src/constructors/basic_constructors.c b/src/vendor/cigraph/src/constructors/basic_constructors.c index 6cb9751e388..892c3cda350 100644 --- a/src/vendor/cigraph/src/constructors/basic_constructors.c +++ b/src/vendor/cigraph/src/constructors/basic_constructors.c @@ -121,7 +121,7 @@ igraph_error_t igraph_create(igraph_t *graph, const igraph_vector_int_t *edges, * The graph to be created will be \em undirected. * \endclist * \param ... The additional arguments giving the edges of the graph, - * and \em must be of type intint. Don't forget to supply an * additional -1 after the last (meaningful) argument. The * \p first parameter is present for technical reasons and represents * the first variadic argument. diff --git a/src/vendor/cigraph/src/constructors/de_bruijn.c b/src/vendor/cigraph/src/constructors/de_bruijn.c index 6090dcc975e..e7a55d2b7e4 100644 --- a/src/vendor/cigraph/src/constructors/de_bruijn.c +++ b/src/vendor/cigraph/src/constructors/de_bruijn.c @@ -102,10 +102,7 @@ igraph_error_t igraph_de_bruijn(igraph_t *graph, igraph_integer_t m, igraph_inte igraph_vector_int_push_back(&edges, i); igraph_vector_int_push_back(&edges, basis + j); } - if (++iter >= (1 << 10)) { - iter = 0; - IGRAPH_ALLOW_INTERRUPTION(); - } + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 10); } IGRAPH_CHECK(igraph_create(graph, &edges, no_of_nodes, IGRAPH_DIRECTED)); diff --git a/src/vendor/cigraph/src/constructors/kautz.c b/src/vendor/cigraph/src/constructors/kautz.c index f613de05108..7684847b341 100644 --- a/src/vendor/cigraph/src/constructors/kautz.c +++ b/src/vendor/cigraph/src/constructors/kautz.c @@ -151,7 +151,7 @@ igraph_error_t igraph_kautz(igraph_t *graph, igraph_integer_t m, igraph_integer_ } /* not yet, we need a valid prefix now */ - while (1) { + while (true) { /* try to increase digits at position actb */ igraph_integer_t next = VECTOR(digits)[actb] + 1; if (actb != 0 && VECTOR(digits)[actb - 1] == next) { @@ -194,9 +194,7 @@ igraph_error_t igraph_kautz(igraph_t *graph, igraph_integer_t m, igraph_integer_ IGRAPH_CHECK(igraph_vector_int_push_back(&edges, i)); IGRAPH_CHECK(igraph_vector_int_push_back(&edges, to)); } - if (++iter >= (1 << 10)) { - IGRAPH_ALLOW_INTERRUPTION(); - } + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 10); } igraph_vector_int_destroy(&index2); diff --git a/src/vendor/cigraph/src/constructors/regular.c b/src/vendor/cigraph/src/constructors/regular.c index 9a3267a054d..2245ec3d718 100644 --- a/src/vendor/cigraph/src/constructors/regular.c +++ b/src/vendor/cigraph/src/constructors/regular.c @@ -362,6 +362,7 @@ igraph_error_t igraph_square_lattice( igraph_integer_t *coords, *weights; igraph_integer_t i, j; int carry, pos; + int iter; if (igraph_vector_int_any_smaller(dimvector, 0)) { IGRAPH_ERROR("Invalid dimension vector.", IGRAPH_EINVAL); @@ -410,7 +411,7 @@ igraph_error_t igraph_square_lattice( #define IS_PERIODIC(dim) ((periodic && VECTOR(*periodic)[dim])) for (i = 0; i < no_of_nodes; i++) { - IGRAPH_ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 10); /* Connect the current node to the "next" node along each dimension */ for (j = 0; j < dims; j++) { diff --git a/src/vendor/cigraph/src/core/buckets.c b/src/vendor/cigraph/src/core/buckets.c index ab1b4350de1..d2204cd99e3 100644 --- a/src/vendor/cigraph/src/core/buckets.c +++ b/src/vendor/cigraph/src/core/buckets.c @@ -21,8 +21,6 @@ */ -#include "igraph_types.h" - #include "core/buckets.h" /* The igraph_buckets_t data structure can store at most 'size' diff --git a/src/vendor/cigraph/src/core/interruption.h b/src/vendor/cigraph/src/core/interruption.h index a90ac88a804..98cbafbf3c7 100644 --- a/src/vendor/cigraph/src/core/interruption.h +++ b/src/vendor/cigraph/src/core/interruption.h @@ -52,6 +52,30 @@ extern IGRAPH_THREAD_LOCAL igraph_interruption_handler_t *igraph_i_interruption_ } \ } while (0) +/** + * \define IGRAPH_ALLOW_INTERRUPTION_LIMITED + * + * This is a variant of IGRAPH_ALLOW_INTERRUPTION() that checks for interruption + * only on every 'skips' call. The 'iter' macro parameter is the name of a variable, + * usually of type 'int', that is used to count calls to this macto. It must be declared + * separately, outside of the loop where IGRAPH_ALLOW_INTERRUPTION_LIMITED() is called, + * and initialized to 0. Example: + * + * int myiter = 0; + * for (igraph_integer_t i=0; i < n; i++) { + * // Allow for interruption every 1000th iteration + * IGRAPH_ALLOW_INTERRUPTION_LIMITED(myiter, 1000); + * } + * + */ +#define IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, skips) \ + do { \ + if (++iter >= skips) { \ + IGRAPH_ALLOW_INTERRUPTION(); \ + iter = 0; \ + } \ + } while (0) + __END_DECLS #endif diff --git a/src/vendor/cigraph/src/core/matrix.pmt b/src/vendor/cigraph/src/core/matrix.pmt index 8676aca3be9..64418149cf5 100644 --- a/src/vendor/cigraph/src/core/matrix.pmt +++ b/src/vendor/cigraph/src/core/matrix.pmt @@ -842,12 +842,8 @@ FUNCTION(igraph_matrix, all_ge)(const TYPE(igraph_matrix) *lhs, igraph_real_t FUNCTION(igraph_matrix, maxdifference)(const TYPE(igraph_matrix) *m1, const TYPE(igraph_matrix) *m2) { - igraph_integer_t col1 = FUNCTION(igraph_matrix, ncol)(m1); - igraph_integer_t col2 = FUNCTION(igraph_matrix, ncol)(m2); - igraph_integer_t row1 = FUNCTION(igraph_matrix, nrow)(m1); - igraph_integer_t row2 = FUNCTION(igraph_matrix, nrow)(m2); - if (col1 != col2 || row1 != row2) { - IGRAPH_WARNING("Comparing non-conformant matrices"); + if (m1->ncol != m2->ncol || m1->nrow != m2->nrow) { + IGRAPH_WARNING("Comparing non-conformant matrices."); } return FUNCTION(igraph_vector, maxdifference)(&m1->data, &m2->data); } @@ -1186,16 +1182,15 @@ igraph_error_t FUNCTION(igraph_matrix, get_row)(const TYPE(igraph_matrix) *m, igraph_error_t FUNCTION(igraph_matrix, set_row)(TYPE(igraph_matrix) *m, const TYPE(igraph_vector) *v, igraph_integer_t index) { - igraph_integer_t rows = m->nrow, cols = m->ncol; - igraph_integer_t i, j; + const igraph_integer_t rows = m->nrow, cols = m->ncol; if (index >= rows) { - IGRAPH_ERROR("Index out of range for selecting matrix row", IGRAPH_EINVAL); + IGRAPH_ERROR("Index out of range for selecting matrix row.", IGRAPH_EINVAL); } if (FUNCTION(igraph_vector, size)(v) != cols) { - IGRAPH_ERROR("Cannot set matrix row, invalid vector length", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot set matrix row, invalid vector length.", IGRAPH_EINVAL); } - for (i = index, j = 0; j < cols; i += rows, j++) { + for (igraph_integer_t i = index, j = 0; j < cols; i += rows, j++) { VECTOR(m->data)[i] = VECTOR(*v)[j]; } return IGRAPH_SUCCESS; @@ -1219,16 +1214,15 @@ igraph_error_t FUNCTION(igraph_matrix, set_row)(TYPE(igraph_matrix) *m, igraph_error_t FUNCTION(igraph_matrix, set_col)(TYPE(igraph_matrix) *m, const TYPE(igraph_vector) *v, igraph_integer_t index) { - igraph_integer_t rows = m->nrow, cols = m->ncol; - igraph_integer_t i, j; + const igraph_integer_t rows = m->nrow, cols = m->ncol; if (index >= cols) { - IGRAPH_ERROR("Index out of range for setting matrix column", IGRAPH_EINVAL); + IGRAPH_ERROR("Index out of range for setting matrix column.", IGRAPH_EINVAL); } if (FUNCTION(igraph_vector, size)(v) != rows) { - IGRAPH_ERROR("Cannot set matrix column, invalid vector length", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot set matrix column, invalid vector length.", IGRAPH_EINVAL); } - for (i = index * rows, j = 0; j < rows; i++, j++) { + for (igraph_integer_t i = index * rows, j = 0; j < rows; i++, j++) { VECTOR(m->data)[i] = VECTOR(*v)[j]; } return IGRAPH_SUCCESS; @@ -1249,16 +1243,16 @@ igraph_error_t FUNCTION(igraph_matrix, set_col)(TYPE(igraph_matrix) *m, igraph_error_t FUNCTION(igraph_matrix, swap_rows)(TYPE(igraph_matrix) *m, igraph_integer_t i, igraph_integer_t j) { - igraph_integer_t ncol = m->ncol, nrow = m->nrow; - igraph_integer_t n = nrow * ncol; - igraph_integer_t index1, index2; + const igraph_integer_t ncol = m->ncol, nrow = m->nrow; + const igraph_integer_t n = nrow * ncol; + if (i >= nrow || j >= nrow) { IGRAPH_ERROR("Cannot swap rows, index out of range", IGRAPH_EINVAL); } if (i == j) { return IGRAPH_SUCCESS; } - for (index1 = i, index2 = j; index1 < n; index1 += nrow, index2 += nrow) { + for (igraph_integer_t index1 = i, index2 = j; index1 < n; index1 += nrow, index2 += nrow) { BASE tmp; tmp = VECTOR(m->data)[index1]; VECTOR(m->data)[index1] = VECTOR(m->data)[index2]; @@ -1282,15 +1276,15 @@ igraph_error_t FUNCTION(igraph_matrix, swap_rows)(TYPE(igraph_matrix) *m, igraph_error_t FUNCTION(igraph_matrix, swap_cols)(TYPE(igraph_matrix) *m, igraph_integer_t i, igraph_integer_t j) { - igraph_integer_t ncol = m->ncol, nrow = m->nrow; - igraph_integer_t k, index1, index2; + const igraph_integer_t ncol = m->ncol, nrow = m->nrow; + if (i >= ncol || j >= ncol) { - IGRAPH_ERROR("Cannot swap columns, index out of range", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot swap columns, index out of range.", IGRAPH_EINVAL); } if (i == j) { return IGRAPH_SUCCESS; } - for (index1 = i * nrow, index2 = j * nrow, k = 0; k < nrow; k++, index1++, index2++) { + for (igraph_integer_t index1 = i * nrow, index2 = j * nrow, k = 0; k < nrow; k++, index1++, index2++) { BASE tmp = VECTOR(m->data)[index1]; VECTOR(m->data)[index1] = VECTOR(m->data)[index2]; VECTOR(m->data)[index2] = tmp; @@ -1356,10 +1350,11 @@ igraph_error_t FUNCTION(igraph_matrix, sub)(TYPE(igraph_matrix) *m1, /** * \function igraph_matrix_mul_elements - * Elementwise multiplication. + * \brief Elementwise matrix multiplication. * * Multiply \p m1 by \p m2 elementwise and store the result in \p m1. * The dimensions of the two matrices must match. + * * \param m1 The first matrix; the result is stored here. * \param m2 The second matrix; it is left unchanged. * \return Error code. @@ -1370,7 +1365,7 @@ igraph_error_t FUNCTION(igraph_matrix, sub)(TYPE(igraph_matrix) *m1, igraph_error_t FUNCTION(igraph_matrix, mul_elements)(TYPE(igraph_matrix) *m1, const TYPE(igraph_matrix) *m2) { if (m1->nrow != m2->nrow || m1->ncol != m2->ncol) { - IGRAPH_ERROR("Cannot multiply non-conformant matrices", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot multiply elements of non-conformant matrices.", IGRAPH_EINVAL); } return FUNCTION(igraph_vector, mul)(&m1->data, &m2->data); } @@ -1391,7 +1386,7 @@ igraph_error_t FUNCTION(igraph_matrix, mul_elements)(TYPE(igraph_matrix) *m1, igraph_error_t FUNCTION(igraph_matrix, div_elements)(TYPE(igraph_matrix) *m1, const TYPE(igraph_matrix) *m2) { if (m1->nrow != m2->nrow || m1->ncol != m2->ncol) { - IGRAPH_ERROR("Cannot divide non-conformant matrices", IGRAPH_EINVAL); + IGRAPH_ERROR("Cannot divide non-conformant matrices.", IGRAPH_EINVAL); } return FUNCTION(igraph_vector, div)(&m1->data, &m2->data); } @@ -1521,9 +1516,10 @@ void FUNCTION(igraph_matrix, which_minmax)(const TYPE(igraph_matrix) *m, /** * \function igraph_matrix_isnull - * Check for a null matrix. + * \brief Checks for a null matrix. * * Checks whether all elements are zero. + * * \param m The input matrix. * \return Boolean, \c true is \p m contains only zeros and \c false * otherwise. @@ -1537,10 +1533,11 @@ igraph_bool_t FUNCTION(igraph_matrix, isnull)(const TYPE(igraph_matrix) *m) { /** * \function igraph_matrix_empty - * Check for an empty matrix. + * \brief Is the matrix empty? * * It is possible to have a matrix with zero rows or zero columns, or * even both. This functions checks for these. + * * \param m The input matrix. * \return Boolean, \c true if the matrix contains zero elements, and * \c false otherwise. @@ -1554,9 +1551,10 @@ igraph_bool_t FUNCTION(igraph_matrix, empty)(const TYPE(igraph_matrix) *m) { /** * \function igraph_matrix_is_symmetric - * Check for symmetric matrix. + * \brief Is the matrix symmetric? * * A non-square matrix is not symmetric by definition. + * * \param m The input matrix. * \return Boolean, \c true if the matrix is square and symmetric, \c * false otherwise. @@ -1567,13 +1565,12 @@ igraph_bool_t FUNCTION(igraph_matrix, empty)(const TYPE(igraph_matrix) *m) { igraph_bool_t FUNCTION(igraph_matrix, is_symmetric)(const TYPE(igraph_matrix) *m) { - igraph_integer_t n = m->nrow; - igraph_integer_t r, c; + const igraph_integer_t n = m->nrow; if (m->ncol != n) { return false; } - for (r = 1; r < n; r++) { - for (c = 0; c < r; c++) { + for (igraph_integer_t r = 1; r < n; r++) { + for (igraph_integer_t c = 0; c < r; c++) { BASE a1 = MATRIX(*m, r, c); BASE a2 = MATRIX(*m, c, r); #ifdef EQ @@ -1592,10 +1589,11 @@ igraph_bool_t FUNCTION(igraph_matrix, is_symmetric)(const TYPE(igraph_matrix) *m /** * \function igraph_matrix_prod - * Product of the elements. + * \brief Product of all matrix elements. + * + * Note that this function can result in overflow easily, even for not too + * big matrices. Overflow is not checked. * - * Note this function can result in overflow easily, even for not too - * big matrices. * \param m The input matrix. * \return The product of the elements. * @@ -1608,9 +1606,10 @@ BASE FUNCTION(igraph_matrix, prod)(const TYPE(igraph_matrix) *m) { /** * \function igraph_matrix_rowsum - * Rowwise sum. + * \brief Rowwise sum. * * Calculate the sum of the elements in each row. + * * \param m The input matrix. * \param res Pointer to an initialized vector; the result is stored * here. It will be resized if necessary. @@ -1621,12 +1620,11 @@ BASE FUNCTION(igraph_matrix, prod)(const TYPE(igraph_matrix) *m) { igraph_error_t FUNCTION(igraph_matrix, rowsum)(const TYPE(igraph_matrix) *m, TYPE(igraph_vector) *res) { - igraph_integer_t nrow = m->nrow, ncol = m->ncol; - igraph_integer_t r, c; + const igraph_integer_t nrow = m->nrow, ncol = m->ncol; IGRAPH_CHECK(FUNCTION(igraph_vector, resize)(res, nrow)); - for (r = 0; r < nrow; r++) { + for (igraph_integer_t r = 0; r < nrow; r++) { BASE sum = ZERO; - for (c = 0; c < ncol; c++) { + for (igraph_integer_t c = 0; c < ncol; c++) { #ifdef SUM SUM(sum, sum, MATRIX(*m, r, c)); #else @@ -1640,9 +1638,10 @@ igraph_error_t FUNCTION(igraph_matrix, rowsum)(const TYPE(igraph_matrix) *m, /** * \function igraph_matrix_colsum - * Columnwise sum. + * \brief Columnwise sum. * * Calculate the sum of the elements in each column. + * * \param m The input matrix. * \param res Pointer to an initialized vector; the result is stored * here. It will be resized if necessary. @@ -1653,12 +1652,11 @@ igraph_error_t FUNCTION(igraph_matrix, rowsum)(const TYPE(igraph_matrix) *m, igraph_error_t FUNCTION(igraph_matrix, colsum)(const TYPE(igraph_matrix) *m, TYPE(igraph_vector) *res) { - igraph_integer_t nrow = m->nrow, ncol = m->ncol; - igraph_integer_t r, c; + const igraph_integer_t nrow = m->nrow, ncol = m->ncol; IGRAPH_CHECK(FUNCTION(igraph_vector, resize)(res, ncol)); - for (c = 0; c < ncol; c++) { + for (igraph_integer_t c = 0; c < ncol; c++) { BASE sum = ZERO; - for (r = 0; r < nrow; r++) { + for (igraph_integer_t r = 0; r < nrow; r++) { #ifdef SUM SUM(sum, sum, MATRIX(*m, r, c)); #else diff --git a/src/vendor/cigraph/src/core/trie.c b/src/vendor/cigraph/src/core/trie.c index a2990d31164..d81ccbf7f2b 100644 --- a/src/vendor/cigraph/src/core/trie.c +++ b/src/vendor/cigraph/src/core/trie.c @@ -72,12 +72,11 @@ igraph_error_t igraph_trie_init(igraph_trie_t *t, igraph_bool_t storekeys) { } static void igraph_i_trie_destroy_node_helper(igraph_trie_node_t *t, igraph_bool_t sfree) { - igraph_integer_t i; igraph_strvector_destroy(&t->strs); igraph_integer_t children_size = igraph_vector_ptr_size(&t->children); - for (i = 0; i < children_size; i++) { + for (igraph_integer_t i = 0; i < children_size; i++) { igraph_trie_node_t *child = VECTOR(t->children)[i]; - if (child != 0) { + if (child != NULL) { igraph_i_trie_destroy_node_helper(child, true); } } @@ -128,18 +127,14 @@ static igraph_error_t igraph_i_trie_get_node( igraph_trie_node_t *t, const char *key, igraph_integer_t newvalue, igraph_integer_t *id ) { - const char *str; - igraph_integer_t i; - igraph_bool_t add; - /* If newvalue is negative, we don't add the node if nonexistent, only check * for its existence */ - add = (newvalue >= 0); + igraph_bool_t add = (newvalue >= 0); igraph_integer_t strs_size = igraph_strvector_size(&t->strs); - for (i = 0; i < strs_size; i++) { + for (igraph_integer_t i = 0; i < strs_size; i++) { size_t diff; - str = igraph_strvector_get(&t->strs, i); + const char *str = igraph_strvector_get(&t->strs, i); diff = igraph_i_strdiff(str, key); if (diff == 0) { @@ -165,24 +160,23 @@ static igraph_error_t igraph_i_trie_get_node( /* ------------------------------------ */ /* str is prefix of key, follow its link if there is one */ igraph_trie_node_t *node = VECTOR(t->children)[i]; - if (node != 0) { + if (node != NULL) { return igraph_i_trie_get_node(node, key + diff, newvalue, id); } else if (add) { - igraph_trie_node_t *node = IGRAPH_CALLOC(1, igraph_trie_node_t); - if (! node) { - IGRAPH_ERROR("Cannot add to trie.", IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ - } - IGRAPH_FINALLY(igraph_free, node); - IGRAPH_STRVECTOR_INIT_FINALLY(&node->strs, 1); - IGRAPH_VECTOR_PTR_INIT_FINALLY(&node->children, 1); - IGRAPH_VECTOR_INT_INIT_FINALLY(&node->values, 1); - IGRAPH_CHECK(igraph_strvector_set(&node->strs, 0, key + diff)); + igraph_trie_node_t *new_node = IGRAPH_CALLOC(1, igraph_trie_node_t); + IGRAPH_CHECK_OOM(new_node, "Cannot add to trie."); + IGRAPH_FINALLY(igraph_free, new_node); + + IGRAPH_STRVECTOR_INIT_FINALLY(&new_node->strs, 1); + IGRAPH_VECTOR_PTR_INIT_FINALLY(&new_node->children, 1); + IGRAPH_VECTOR_INT_INIT_FINALLY(&new_node->values, 1); + IGRAPH_CHECK(igraph_strvector_set(&new_node->strs, 0, key + diff)); IGRAPH_FINALLY_CLEAN(4); - VECTOR(node->children)[0] = 0; - VECTOR(node->values)[0] = newvalue; + VECTOR(new_node->children)[0] = 0; + VECTOR(new_node->values)[0] = newvalue; - VECTOR(t->children)[i] = node; + VECTOR(t->children)[i] = new_node; *id = newvalue; return IGRAPH_SUCCESS; @@ -198,10 +192,9 @@ static igraph_error_t igraph_i_trie_get_node( char *str2; igraph_trie_node_t *node = IGRAPH_CALLOC(1, igraph_trie_node_t); - if (! node) { - IGRAPH_ERROR("Cannot add to trie.", IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ - } + IGRAPH_CHECK_OOM(node, "Cannot add to trie."); IGRAPH_FINALLY(igraph_free, node); + IGRAPH_STRVECTOR_INIT_FINALLY(&node->strs, 1); IGRAPH_VECTOR_PTR_INIT_FINALLY(&node->children, 1); IGRAPH_VECTOR_INT_INIT_FINALLY(&node->values, 1); @@ -212,9 +205,8 @@ static igraph_error_t igraph_i_trie_get_node( str2 = strdup(str); IGRAPH_CHECK_OOM(str2, "Cannot add to trie."); - - str2[diff] = '\0'; IGRAPH_FINALLY(igraph_free, str2); + str2[diff] = '\0'; IGRAPH_CHECK(igraph_strvector_set(&t->strs, i, str2)); @@ -234,10 +226,9 @@ static igraph_error_t igraph_i_trie_get_node( char *str2; igraph_trie_node_t *node = IGRAPH_CALLOC(1, igraph_trie_node_t); - if (! node) { - IGRAPH_ERROR("Cannot add to trie.", IGRAPH_ENOMEM); /* LCOV_EXCL_LINE */ - } + IGRAPH_CHECK_OOM(node, "Cannot add to trie."); IGRAPH_FINALLY(igraph_free, node); + IGRAPH_STRVECTOR_INIT_FINALLY(&node->strs, 2); IGRAPH_VECTOR_PTR_INIT_FINALLY(&node->children, 2); IGRAPH_VECTOR_INT_INIT_FINALLY(&node->values, 2); diff --git a/src/vendor/cigraph/src/core/vector.c b/src/vendor/cigraph/src/core/vector.c index 92e0dad5ba2..c90eb528ae9 100644 --- a/src/vendor/cigraph/src/core/vector.c +++ b/src/vendor/cigraph/src/core/vector.c @@ -76,10 +76,10 @@ * Time complexity: O(n), where n is the number of elements in the vector. */ igraph_error_t igraph_vector_floor(const igraph_vector_t *from, igraph_vector_int_t *to) { - igraph_integer_t i, n = igraph_vector_size(from); + const igraph_integer_t n = igraph_vector_size(from); IGRAPH_CHECK(igraph_vector_int_resize(to, n)); - for (i = 0; i < n; i++) { + for (igraph_integer_t i = 0; i < n; i++) { VECTOR(*to)[i] = floor(VECTOR(*from)[i]); } @@ -87,10 +87,10 @@ igraph_error_t igraph_vector_floor(const igraph_vector_t *from, igraph_vector_in } igraph_error_t igraph_vector_round(const igraph_vector_t *from, igraph_vector_int_t *to) { - igraph_integer_t i, n = igraph_vector_size(from); + const igraph_integer_t n = igraph_vector_size(from); IGRAPH_CHECK(igraph_vector_int_resize(to, n)); - for (i = 0; i < n; i++) { + for (igraph_integer_t i = 0; i < n; i++) { VECTOR(*to)[i] = round(VECTOR(*from)[i]); } diff --git a/src/vendor/cigraph/src/flow/flow.c b/src/vendor/cigraph/src/flow/flow.c index 956214cc2cc..815051ddf88 100644 --- a/src/vendor/cigraph/src/flow/flow.c +++ b/src/vendor/cigraph/src/flow/flow.c @@ -474,7 +474,7 @@ static igraph_error_t igraph_i_mf_bfs(igraph_dqueue_int_t *bfsq, * \c hi_pr implementation discussed in * B. V. Cherkassky and A. V. Goldberg: On implementing the * push-relabel method for the maximum flow problem, (Algorithmica, - * 19:390--410, 1997) on all the graph classes i've tried. + * 19:390--410, 1997) on all the graph classes I've tried. * * \sa \ref igraph_mincut_value(), \ref igraph_edge_connectivity(), * \ref igraph_vertex_connectivity() for @@ -526,6 +526,9 @@ igraph_error_t igraph_maxflow(const igraph_t *graph, igraph_real_t *value, if (source < 0 || source >= no_of_nodes || target < 0 || target >= no_of_nodes) { IGRAPH_ERROR("Invalid source or target vertex.", IGRAPH_EINVVID); } + if (source == target) { + IGRAPH_ERROR("Source and target vertices are the same.", IGRAPH_EINVAL); + } stats->nopush = stats->norelabel = stats->nogap = stats->nogapnodes = stats->nobfs = 0; @@ -1099,8 +1102,8 @@ igraph_error_t igraph_maxflow_value(const igraph_t *graph, igraph_real_t *value, * * The minimum s-t cut in a weighted (=valued) graph is the * total minimum edge weight needed to remove from the graph to - * eliminate all paths from a given vertex (\c source) to - * another vertex (\c target). Directed paths are considered in + * eliminate all paths from a given vertex (\p source) to + * another vertex (\p target). Directed paths are considered in * directed graphs, and undirected paths in undirected graphs. * * The minimum s-t cut between two vertices is known to be same @@ -1872,16 +1875,18 @@ static igraph_error_t igraph_i_st_vertex_connectivity_undirected(const igraph_t * \function igraph_st_vertex_connectivity * \brief The vertex connectivity of a pair of vertices. * - * The vertex connectivity of two vertices (\c source and - * \c target) is the minimum number of vertices that have to be - * deleted to eliminate all paths from \c source to \c - * target. Directed paths are considered in directed graphs. + * The vertex connectivity of two vertices (\p source and + * \p target) is the minimum number of vertices that must be + * deleted to eliminate all paths from \p source to \p + * target. Directed paths are considered in directed graphs. * - * The vertex connectivity of a pair is the same as the number + * + * The vertex connectivity of a pair is the same as the number * of different (i.e. node-independent) paths from source to - * target. + * target, assuming no direct edges between them. * - * The current implementation uses maximum flow calculations to + * + * The current implementation uses maximum flow calculations to * obtain the result. * * \param graph The input graph. @@ -1896,7 +1901,7 @@ static igraph_error_t igraph_i_st_vertex_connectivity_undirected(const igraph_t * \c IGRAPH_VCONN_NEI_IGNORE, ignore the fact that the two vertices * are connected and calculate the number of vertices needed * to eliminate all paths except for the trivial (direct) paths - * between \p source and \p vertex. TODO: what about neighbors? + * between \p source and \p vertex. * \return Error code. * * Time complexity: O(|V|^3), but see the discussion at \ref @@ -2128,8 +2133,9 @@ static igraph_error_t igraph_i_connectivity_checks(const igraph_t *graph, * and \ref igraph_edge_connectivity(). */ -igraph_error_t igraph_vertex_connectivity(const igraph_t *graph, igraph_integer_t *res, - igraph_bool_t checks) { +igraph_error_t igraph_vertex_connectivity( + const igraph_t *graph, igraph_integer_t *res, + igraph_bool_t checks) { igraph_bool_t ret = false; @@ -2153,12 +2159,11 @@ igraph_error_t igraph_vertex_connectivity(const igraph_t *graph, igraph_integer_ * \function igraph_st_edge_connectivity * \brief Edge connectivity of a pair of vertices. * - * The edge connectivity of two vertices (\c source and - * \c target) in a graph is the minimum number of edges that - * have to be deleted from the graph to eliminate all paths from \c - * source to \c target. + * The edge connectivity of two vertices (\p source and \p target) is the + * minimum number of edges that have to be deleted from the graph to eliminate + * all paths from \p source to \p target. * - * This function uses the maximum flow algorithm to calculate + * This function uses the maximum flow algorithm to calculate * the edge connectivity. * * \param graph The input graph, it has to be directed. @@ -2169,7 +2174,8 @@ igraph_error_t igraph_vertex_connectivity(const igraph_t *graph, igraph_integer_ * * Time complexity: O(|V|^3). * - * \sa \ref igraph_maxflow_value(), \ref igraph_edge_connectivity(), + * \sa \ref igraph_maxflow_value(), \ref igraph_edge_disjoint_paths(), + * \ref igraph_edge_connectivity(), * \ref igraph_st_vertex_connectivity(), \ref * igraph_vertex_connectivity(). */ @@ -2180,7 +2186,7 @@ igraph_error_t igraph_st_edge_connectivity(const igraph_t *graph, igraph_integer igraph_real_t flow; if (source == target) { - IGRAPH_ERROR("source and target vertices are the same", IGRAPH_EINVAL); + IGRAPH_ERROR("The source and target vertices must be different.", IGRAPH_EINVAL); } IGRAPH_CHECK(igraph_maxflow_value(graph, &flow, source, target, 0, 0)); @@ -2255,13 +2261,12 @@ igraph_error_t igraph_edge_connectivity(const igraph_t *graph, igraph_integer_t * \function igraph_edge_disjoint_paths * \brief The maximum number of edge-disjoint paths between two vertices. * - * A set of paths between two vertices is called - * edge-disjoint if they do not share any edges. The maximum number of - * edge-disjoint paths are calculated by this function using maximum - * flow techniques. Directed paths are considered in directed - * graphs. + * A set of paths between two vertices is called edge-disjoint if they do not + * share any edges. The maximum number of edge-disjoint paths are calculated + * by this function using maximum flow techniques. Directed paths are + * considered in directed graphs. * - * Note that the number of disjoint paths is the same as the + * Note that the number of disjoint paths is the same as the * edge connectivity of the two vertices using uniform edge weights. * * \param graph The input graph, can be directed or undirected. @@ -2285,7 +2290,8 @@ igraph_error_t igraph_edge_disjoint_paths(const igraph_t *graph, igraph_integer_ igraph_real_t flow; if (source == target) { - IGRAPH_ERROR("Not implemented for source=target", IGRAPH_UNIMPLEMENTED); + IGRAPH_ERROR("Not implemented when the source and target are the same.", + IGRAPH_UNIMPLEMENTED); } IGRAPH_CHECK(igraph_maxflow_value(graph, &flow, source, target, 0, 0)); @@ -2299,13 +2305,17 @@ igraph_error_t igraph_edge_disjoint_paths(const igraph_t *graph, igraph_integer_ * \function igraph_vertex_disjoint_paths * \brief Maximum number of vertex-disjoint paths between two vertices. * - * A set of paths between two vertices is called - * vertex-disjoint if they share no vertices. The calculation is - * performed by using maximum flow techniques. + * A set of paths between two vertices is called vertex-disjoint if + * they share no vertices, other than the endpoints. This function computes + * the largest number of such paths that can be constructed between + * a source and a target vertex. The calculation is performed by using maximum + * flow techniques. * - * Note that the number of vertex-disjoint paths is the same as - * the vertex connectivity of the two vertices in most cases (if the - * two vertices are not connected by an edge). + * + * When there are no edges from the source to the target, the number of + * vertex-disjoint paths is the same as the vertex connectivity of + * the two vertices. When some edges are present, each one of them + * contributes one extra path. * * \param graph The input graph. * \param res Pointer to an integer variable, the result will be @@ -2316,67 +2326,39 @@ igraph_error_t igraph_edge_disjoint_paths(const igraph_t *graph, igraph_integer_ * * Time complexity: O(|V|^3). * - * \sa \ref igraph_edge_disjoint_paths(), \ref - * igraph_vertex_connectivity(), \ref igraph_maxflow_value(). + * \sa \ref igraph_edge_disjoint_paths(), + * \ref igraph_st_vertex_connectivity(), \ref igraph_maxflow_value(). */ igraph_error_t igraph_vertex_disjoint_paths(const igraph_t *graph, igraph_integer_t *res, igraph_integer_t source, igraph_integer_t target) { - igraph_bool_t conn; + igraph_vector_int_t eids; if (source == target) { - IGRAPH_ERROR("The source==target case is not implemented", + IGRAPH_ERROR("Not implemented when the source and target are the same.", IGRAPH_UNIMPLEMENTED); } - IGRAPH_CHECK(igraph_are_connected(graph, source, target, &conn)); - if (conn) { - /* We need to remove every (possibly directed) edge between source - and target and calculate the disjoint paths on the new - graph. Finally we add 1 for each removed connection. */ - igraph_es_t es; - igraph_t newgraph; - igraph_integer_t num_removed_edges; - - IGRAPH_CHECK(igraph_es_all_between(&es, source, target, IGRAPH_DIRECTED)); - IGRAPH_FINALLY(igraph_es_destroy, &es); - - IGRAPH_CHECK(igraph_copy(&newgraph, graph)); - IGRAPH_FINALLY(igraph_destroy, &newgraph); - IGRAPH_CHECK(igraph_delete_edges(&newgraph, es)); - num_removed_edges = igraph_ecount(graph) - igraph_ecount(&newgraph); - - if (igraph_is_directed(graph)) { - IGRAPH_CHECK(igraph_i_st_vertex_connectivity_directed(&newgraph, res, - source, target, - IGRAPH_VCONN_NEI_IGNORE)); - } else { - IGRAPH_CHECK(igraph_i_st_vertex_connectivity_undirected(&newgraph, res, - source, target, - IGRAPH_VCONN_NEI_IGNORE)); - } - - if (res) { - *res += num_removed_edges; - } + IGRAPH_VECTOR_INT_INIT_FINALLY(&eids, 4); + IGRAPH_CHECK(igraph_get_all_eids_between(graph, &eids, source, target, /*directed*/ true)); - IGRAPH_FINALLY_CLEAN(2); - igraph_destroy(&newgraph); - igraph_es_destroy(&es); - } else { - if (igraph_is_directed(graph)) { - IGRAPH_CHECK(igraph_i_st_vertex_connectivity_directed(graph, res, + if (igraph_is_directed(graph)) { + IGRAPH_CHECK(igraph_i_st_vertex_connectivity_directed(graph, res, source, target, IGRAPH_VCONN_NEI_IGNORE)); - } else { - IGRAPH_CHECK(igraph_i_st_vertex_connectivity_undirected(graph, res, + } else { + IGRAPH_CHECK(igraph_i_st_vertex_connectivity_undirected(graph, res, source, target, IGRAPH_VCONN_NEI_IGNORE)); - } } + *res += igraph_vector_int_size(&eids); + + igraph_vector_int_destroy(&eids); + IGRAPH_FINALLY_CLEAN(1); + return IGRAPH_SUCCESS; } diff --git a/src/vendor/cigraph/src/flow/st-cuts.c b/src/vendor/cigraph/src/flow/st-cuts.c index 103ac2c6034..6bf0a05e588 100644 --- a/src/vendor/cigraph/src/flow/st-cuts.c +++ b/src/vendor/cigraph/src/flow/st-cuts.c @@ -1373,7 +1373,7 @@ igraph_error_t igraph_all_st_mincuts(const igraph_t *graph, igraph_real_t *value igraph_vector_bool_t VE1bool; igraph_integer_t i, nocuts; igraph_integer_t proj_nodes; - igraph_vector_t revmap_ptr, revmap_next; + igraph_vector_int_t revmap_ptr, revmap_next; igraph_vector_int_list_t closedsets; igraph_vector_int_list_t *mypartition1s = partition1s, vpartition1s; igraph_maxflow_stats_t stats; @@ -1478,8 +1478,8 @@ igraph_error_t igraph_all_st_mincuts(const igraph_t *graph, igraph_real_t *value /* Convert the closed sets in the contracted graphs to cutsets in the original graph */ - IGRAPH_VECTOR_INIT_FINALLY(&revmap_ptr, igraph_vcount(&residual)); - IGRAPH_VECTOR_INIT_FINALLY(&revmap_next, no_of_nodes); + IGRAPH_VECTOR_INT_INIT_FINALLY(&revmap_ptr, igraph_vcount(&residual)); + IGRAPH_VECTOR_INT_INIT_FINALLY(&revmap_next, no_of_nodes); for (i = 0; i < no_of_nodes; i++) { igraph_integer_t id = VECTOR(NtoL)[i]; VECTOR(revmap_next)[i] = VECTOR(revmap_ptr)[id]; @@ -1510,8 +1510,8 @@ igraph_error_t igraph_all_st_mincuts(const igraph_t *graph, igraph_real_t *value /* TODO: we could already reclaim the memory taken by 'supercut' here */ } - igraph_vector_destroy(&revmap_next); - igraph_vector_destroy(&revmap_ptr); + igraph_vector_int_destroy(&revmap_next); + igraph_vector_int_destroy(&revmap_ptr); igraph_vector_int_list_destroy(&closedsets); IGRAPH_FINALLY_CLEAN(3); diff --git a/src/vendor/cigraph/src/games/erdos_renyi.c b/src/vendor/cigraph/src/games/erdos_renyi.c index eff7e62e221..b7b2dbd6dee 100644 --- a/src/vendor/cigraph/src/games/erdos_renyi.c +++ b/src/vendor/cigraph/src/games/erdos_renyi.c @@ -31,12 +31,6 @@ #include "math/safe_intop.h" #include "random/random_internal.h" -#define ALLOW_INTERRUPTION() \ - if (++iter >= (1 << 14)) { \ - IGRAPH_ALLOW_INTERRUPTION(); \ - iter = 0; \ - } - /** * \section about_games * @@ -125,7 +119,7 @@ igraph_error_t igraph_erdos_renyi_game_gnp( IGRAPH_CHECK(igraph_vector_push_back(&s, last)); last += RNG_GEOM(p); last += 1; - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } RNG_END(); @@ -141,7 +135,7 @@ igraph_error_t igraph_erdos_renyi_game_gnp( igraph_integer_t from = VECTOR(s)[i] - to * no_of_nodes_real; igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } else if (directed && !loops) { for (igraph_integer_t i = 0; i < vsize; i++) { @@ -152,7 +146,7 @@ igraph_error_t igraph_erdos_renyi_game_gnp( } igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } else if (!directed && loops) { for (igraph_integer_t i = 0; i < vsize; i++) { @@ -160,7 +154,7 @@ igraph_error_t igraph_erdos_renyi_game_gnp( igraph_integer_t from = VECTOR(s)[i] - (((igraph_real_t)to) * (to + 1)) / 2; igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } else { /* !directed && !loops */ for (igraph_integer_t i = 0; i < vsize; i++) { @@ -168,7 +162,7 @@ igraph_error_t igraph_erdos_renyi_game_gnp( igraph_integer_t from = VECTOR(s)[i] - (((igraph_real_t)to) * (to - 1)) / 2; igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } @@ -270,7 +264,7 @@ igraph_error_t igraph_erdos_renyi_game_gnm( igraph_integer_t from = VECTOR(s)[i] - to * no_of_nodes_real; igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } else if (directed && !loops) { for (i = 0; i < slen; i++) { @@ -281,7 +275,7 @@ igraph_error_t igraph_erdos_renyi_game_gnm( } igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } else if (!directed && loops) { for (i = 0; i < slen; i++) { @@ -289,7 +283,7 @@ igraph_error_t igraph_erdos_renyi_game_gnm( igraph_integer_t from = VECTOR(s)[i] - (((igraph_real_t)to) * (to + 1)) / 2; igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } else { /* !directed && !loops */ for (i = 0; i < slen; i++) { @@ -297,7 +291,7 @@ igraph_error_t igraph_erdos_renyi_game_gnm( igraph_integer_t from = VECTOR(s)[i] - (((igraph_real_t)to) * (to - 1)) / 2; igraph_vector_int_push_back(&edges, from); igraph_vector_int_push_back(&edges, to); - ALLOW_INTERRUPTION(); + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 14); } } diff --git a/src/vendor/cigraph/src/games/recent_degree.c b/src/vendor/cigraph/src/games/recent_degree.c index 5564fcaaf0f..c4d101a8a38 100644 --- a/src/vendor/cigraph/src/games/recent_degree.c +++ b/src/vendor/cigraph/src/games/recent_degree.c @@ -91,7 +91,7 @@ igraph_error_t igraph_recent_degree_game(igraph_t *graph, igraph_integer_t nodes IGRAPH_EINVAL, igraph_vector_int_size(outseq), no_of_nodes); } if (!have_outseq && m < 0) { - IGRAPH_ERRORF("Numer of edges per step cannot be negative, got %" IGRAPH_PRId ".", + IGRAPH_ERRORF("Number of edges per step cannot be negative, got %" IGRAPH_PRId ".", IGRAPH_EINVAL, m); } if (time_window < 0) { diff --git a/src/vendor/cigraph/src/graph/adjlist.c b/src/vendor/cigraph/src/graph/adjlist.c index 75e404c6848..b4b6a088cbe 100644 --- a/src/vendor/cigraph/src/graph/adjlist.c +++ b/src/vendor/cigraph/src/graph/adjlist.c @@ -27,7 +27,6 @@ #include "core/interruption.h" -#include /* memset */ #include /** diff --git a/src/vendor/cigraph/src/graph/attributes.c b/src/vendor/cigraph/src/graph/attributes.c index 8c1226454bc..731d628d9d3 100644 --- a/src/vendor/cigraph/src/graph/attributes.c +++ b/src/vendor/cigraph/src/graph/attributes.c @@ -32,10 +32,10 @@ /* Should you ever want to have a thread-local attribute handler table, prepend * IGRAPH_THREAD_LOCAL to the following declaration and #include "config.h". */ -igraph_attribute_table_t *igraph_i_attribute_table = 0; +igraph_attribute_table_t *igraph_i_attribute_table = NULL; igraph_error_t igraph_i_attribute_init(igraph_t *graph, void *attr) { - graph->attr = 0; + graph->attr = NULL; if (igraph_i_attribute_table) { return igraph_i_attribute_table->init(graph, attr); } else { @@ -47,10 +47,12 @@ void igraph_i_attribute_destroy(igraph_t *graph) { if (igraph_i_attribute_table) { igraph_i_attribute_table->destroy(graph); } + graph->attr = NULL; } igraph_error_t igraph_i_attribute_copy(igraph_t *to, const igraph_t *from, igraph_bool_t ga, igraph_bool_t va, igraph_bool_t ea) { + to->attr = NULL; if (igraph_i_attribute_table) { return igraph_i_attribute_table->copy(to, from, ga, va, ea); } else { diff --git a/src/vendor/cigraph/src/graph/attributes.h b/src/vendor/cigraph/src/graph/attributes.h index ef5838bae81..c1ceb3e7a0f 100644 --- a/src/vendor/cigraph/src/graph/attributes.h +++ b/src/vendor/cigraph/src/graph/attributes.h @@ -30,10 +30,9 @@ __BEGIN_DECLS do {if ((graph)->attr) igraph_i_attribute_destroy(graph);} while(0) #define IGRAPH_I_ATTRIBUTE_COPY(to,from,ga,va,ea) do { \ igraph_error_t igraph_i_ret2=IGRAPH_SUCCESS; \ + (to)->attr = NULL; \ if ((from)->attr) { \ IGRAPH_CHECK(igraph_i_ret2=igraph_i_attribute_copy((to),(from),(ga),(va),(ea))); \ - } else { \ - (to)->attr = NULL; \ } \ if (igraph_i_ret2 != IGRAPH_SUCCESS) { \ IGRAPH_ERROR("", igraph_i_ret2); \ diff --git a/src/vendor/cigraph/src/graph/basic_query.c b/src/vendor/cigraph/src/graph/basic_query.c index 3681131eb07..dcb6fad9c1a 100644 --- a/src/vendor/cigraph/src/graph/basic_query.c +++ b/src/vendor/cigraph/src/graph/basic_query.c @@ -31,7 +31,9 @@ * \function igraph_are_connected * \brief Decides whether two vertices are connected. * - * This function is of course symmetric for undirected graphs. + * Decides whether there are any edges that have \p v1 and \p v2 + * as endpoints. This function is of course symmetric for undirected + * graphs. * * \param graph The graph object. * \param v1 The first vertex. diff --git a/src/vendor/cigraph/src/isomorphism/lad.c b/src/vendor/cigraph/src/isomorphism/lad.c index df500df055d..02a4156e2ef 100644 --- a/src/vendor/cigraph/src/isomorphism/lad.c +++ b/src/vendor/cigraph/src/isomorphism/lad.c @@ -1587,7 +1587,10 @@ igraph_error_t igraph_subisomorphic_lad(const igraph_t *pattern, const igraph_t } if (igraph_vcount(pattern) == 0) { - /* Special case for empty graphs */ + /* Special case for null patterns */ + if (maps) { + IGRAPH_CHECK(igraph_vector_int_list_push_back_new(maps, NULL)); + } return IGRAPH_SUCCESS; } diff --git a/src/vendor/cigraph/src/layout/sugiyama.c b/src/vendor/cigraph/src/layout/sugiyama.c index 37eaa740e33..e50debd4b03 100644 --- a/src/vendor/cigraph/src/layout/sugiyama.c +++ b/src/vendor/cigraph/src/layout/sugiyama.c @@ -787,7 +787,7 @@ static igraph_error_t igraph_i_layout_sugiyama_order_nodes_horizontally(const ig layering, layer_index, IGRAPH_IN, layout, &barycenters); #ifdef SUGIYAMA_DEBUG - printf("Layer %ld, aligning to upper barycenters\n", layer_index); + printf("Layer %" IGRAPH_PRId ", aligning to upper barycenters\n", layer_index); printf("Vertices: "); igraph_vector_int_print(layer_members); printf("Barycenters: "); igraph_vector_print(&barycenters); #endif @@ -820,7 +820,7 @@ static igraph_error_t igraph_i_layout_sugiyama_order_nodes_horizontally(const ig layering, layer_index, IGRAPH_OUT, layout, &barycenters); #ifdef SUGIYAMA_DEBUG - printf("Layer %ld, aligning to lower barycenters\n", layer_index); + printf("Layer %" IGRAPH_PRId ", aligning to lower barycenters\n", layer_index); printf("Vertices: "); igraph_vector_int_print(layer_members); printf("Barycenters: "); igraph_vector_print(&barycenters); #endif @@ -845,7 +845,7 @@ static igraph_error_t igraph_i_layout_sugiyama_order_nodes_horizontally(const ig } #ifdef SUGIYAMA_DEBUG - printf("==== Finished iteration %ld\n", iter); + printf("==== Finished iteration %" IGRAPH_PRId "\n", iter); #endif iter++; @@ -868,14 +868,14 @@ static igraph_error_t igraph_i_layout_sugiyama_vertical_alignment(const igraph_t const igraph_i_layering_t* layering, const igraph_matrix_t* layout, const igraph_vector_bool_t* ignored_edges, igraph_bool_t reverse, igraph_bool_t align_right, - igraph_vector_t* roots, igraph_vector_t* align); + igraph_vector_int_t* roots, igraph_vector_int_t* align); static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction(const igraph_t* graph, - const igraph_vector_t* vertex_to_the_left, - const igraph_vector_t* roots, const igraph_vector_t* align, + const igraph_vector_int_t* vertex_to_the_left, + const igraph_vector_int_t* roots, const igraph_vector_int_t* align, igraph_real_t hgap, igraph_vector_t* xs); -static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction_place_block(igraph_integer_t v, - const igraph_vector_t* vertex_to_the_left, - const igraph_vector_t* roots, const igraph_vector_t* align, +static void igraph_i_layout_sugiyama_horizontal_compaction_place_block(igraph_integer_t v, + const igraph_vector_int_t* vertex_to_the_left, + const igraph_vector_int_t* roots, const igraph_vector_int_t* align, igraph_vector_int_t* sinks, igraph_vector_t* shifts, igraph_real_t hgap, igraph_vector_t* xs); @@ -889,8 +889,8 @@ static igraph_error_t igraph_i_layout_sugiyama_place_nodes_horizontally(const ig igraph_integer_t no_of_edges = igraph_ecount(graph); igraph_vector_int_t neis1, neis2; igraph_vector_t xs[4]; - igraph_vector_t roots, align; - igraph_vector_t vertex_to_the_left; + igraph_vector_int_t roots, align; + igraph_vector_int_t vertex_to_the_left; igraph_vector_bool_t ignored_edges; /* @@ -912,7 +912,7 @@ static igraph_error_t igraph_i_layout_sugiyama_place_nodes_horizontally(const ig IGRAPH_CHECK(igraph_vector_bool_init(&ignored_edges, no_of_edges)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &ignored_edges); - IGRAPH_VECTOR_INIT_FINALLY(&vertex_to_the_left, no_of_nodes); + IGRAPH_VECTOR_INT_INIT_FINALLY(&vertex_to_the_left, no_of_nodes); IGRAPH_VECTOR_INT_INIT_FINALLY(&neis1, 0); IGRAPH_VECTOR_INT_INIT_FINALLY(&neis2, 0); @@ -998,8 +998,8 @@ static igraph_error_t igraph_i_layout_sugiyama_place_nodes_horizontally(const ig IGRAPH_VECTOR_INIT_FINALLY(&xs[i], no_of_nodes); } - IGRAPH_VECTOR_INIT_FINALLY(&roots, no_of_nodes); - IGRAPH_VECTOR_INIT_FINALLY(&align, no_of_nodes); + IGRAPH_VECTOR_INT_INIT_FINALLY(&roots, no_of_nodes); + IGRAPH_VECTOR_INT_INIT_FINALLY(&align, no_of_nodes); for (i = 0; i < 4; i++) { IGRAPH_CHECK(igraph_i_layout_sugiyama_vertical_alignment(graph, @@ -1051,8 +1051,8 @@ static igraph_error_t igraph_i_layout_sugiyama_place_nodes_horizontally(const ig VECTOR(xs[2])[i], VECTOR(xs[3])[i]); } - igraph_vector_destroy(&roots); - igraph_vector_destroy(&align); + igraph_vector_int_destroy(&roots); + igraph_vector_int_destroy(&align); IGRAPH_FINALLY_CLEAN(2); for (i = 0; i < 4; i++) { @@ -1060,7 +1060,7 @@ static igraph_error_t igraph_i_layout_sugiyama_place_nodes_horizontally(const ig } IGRAPH_FINALLY_CLEAN(4); - igraph_vector_destroy(&vertex_to_the_left); + igraph_vector_int_destroy(&vertex_to_the_left); IGRAPH_FINALLY_CLEAN(1); igraph_vector_bool_destroy(&ignored_edges); @@ -1073,7 +1073,7 @@ static igraph_error_t igraph_i_layout_sugiyama_vertical_alignment(const igraph_t const igraph_i_layering_t* layering, const igraph_matrix_t* layout, const igraph_vector_bool_t* ignored_edges, igraph_bool_t reverse, igraph_bool_t align_right, - igraph_vector_t* roots, igraph_vector_t* align) { + igraph_vector_int_t* roots, igraph_vector_int_t* align) { igraph_integer_t i, j, k, n, di, dj, i_limit, j_limit, r; igraph_integer_t no_of_layers = igraph_i_layering_num_layers(layering); igraph_integer_t no_of_nodes = igraph_vcount(graph); @@ -1086,8 +1086,8 @@ static igraph_error_t igraph_i_layout_sugiyama_vertical_alignment(const igraph_t IGRAPH_VECTOR_INIT_FINALLY(&xs, 0); IGRAPH_VECTOR_INT_INIT_FINALLY(&inds, 0); - IGRAPH_CHECK(igraph_vector_resize(roots, no_of_nodes)); - IGRAPH_CHECK(igraph_vector_resize(align, no_of_nodes)); + IGRAPH_CHECK(igraph_vector_int_resize(roots, no_of_nodes)); + IGRAPH_CHECK(igraph_vector_int_resize(align, no_of_nodes)); for (i = 0; i < no_of_nodes; i++) { VECTOR(*roots)[i] = VECTOR(*align)[i] = i; @@ -1209,8 +1209,8 @@ static igraph_error_t igraph_i_layout_sugiyama_vertical_alignment(const igraph_t * `hgap` is the preferred horizontal gap between vertices. */ static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction(const igraph_t* graph, - const igraph_vector_t* vertex_to_the_left, - const igraph_vector_t* roots, const igraph_vector_t* align, + const igraph_vector_int_t* vertex_to_the_left, + const igraph_vector_int_t* roots, const igraph_vector_int_t* align, igraph_real_t hgap, igraph_vector_t* xs) { igraph_integer_t i; igraph_integer_t no_of_nodes = igraph_vcount(graph); @@ -1239,10 +1239,8 @@ static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction(const igrap */ for (i = 0; i < no_of_nodes; i++) { if (VECTOR(*roots)[i] == i) { - IGRAPH_CHECK( - igraph_i_layout_sugiyama_horizontal_compaction_place_block(i, - vertex_to_the_left, roots, align, &sinks, &shifts, hgap, xs) - ); + igraph_i_layout_sugiyama_horizontal_compaction_place_block(i, + vertex_to_the_left, roots, align, &sinks, &shifts, hgap, xs); } } @@ -1269,16 +1267,16 @@ static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction(const igrap return IGRAPH_SUCCESS; } -static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction_place_block(igraph_integer_t v, - const igraph_vector_t* vertex_to_the_left, - const igraph_vector_t* roots, const igraph_vector_t* align, +static void igraph_i_layout_sugiyama_horizontal_compaction_place_block(igraph_integer_t v, + const igraph_vector_int_t* vertex_to_the_left, + const igraph_vector_int_t* roots, const igraph_vector_int_t* align, igraph_vector_int_t* sinks, igraph_vector_t* shifts, igraph_real_t hgap, igraph_vector_t* xs) { igraph_integer_t u, w; igraph_integer_t u_sink, v_sink; if (VECTOR(*xs)[v] >= 0) { - return IGRAPH_SUCCESS; + return; } VECTOR(*xs)[v] = 0; @@ -1291,10 +1289,8 @@ static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction_place_block /* Get the root of u (proceeding all the way upwards in the block) */ u = VECTOR(*roots)[u]; /* Place the block of u recursively */ - IGRAPH_CHECK( - igraph_i_layout_sugiyama_horizontal_compaction_place_block(u, - vertex_to_the_left, roots, align, sinks, shifts, hgap, xs) - ); + igraph_i_layout_sugiyama_horizontal_compaction_place_block(u, + vertex_to_the_left, roots, align, sinks, shifts, hgap, xs); u_sink = VECTOR(*sinks)[u]; v_sink = VECTOR(*sinks)[v]; @@ -1323,8 +1319,6 @@ static igraph_error_t igraph_i_layout_sugiyama_horizontal_compaction_place_block /* Follow the alignment */ w = VECTOR(*align)[w]; } while (w != v); - - return IGRAPH_SUCCESS; } #undef IS_INNER_SEGMENT diff --git a/src/vendor/cigraph/src/misc/bipartite.c b/src/vendor/cigraph/src/misc/bipartite.c index 42d462c381d..ab5b94fadc9 100644 --- a/src/vendor/cigraph/src/misc/bipartite.c +++ b/src/vendor/cigraph/src/misc/bipartite.c @@ -670,7 +670,7 @@ igraph_error_t igraph_biadjacency( igraph_integer_t elem = ceil(MATRIX(*input, i, j)); igraph_integer_t from, to; - if (!elem) { + if (elem == 0) { continue; } diff --git a/src/vendor/cigraph/src/misc/cocitation.c b/src/vendor/cigraph/src/misc/cocitation.c index c1210ec42e7..05ab3d8397d 100644 --- a/src/vendor/cigraph/src/misc/cocitation.c +++ b/src/vendor/cigraph/src/misc/cocitation.c @@ -24,7 +24,6 @@ #include "igraph_cocitation.h" -#include "igraph_memory.h" #include "igraph_adjlist.h" #include "igraph_interface.h" @@ -449,6 +448,7 @@ igraph_error_t igraph_similarity_jaccard(const igraph_t *graph, igraph_matrix_t */ igraph_error_t igraph_similarity_jaccard_pairs(const igraph_t *graph, igraph_vector_t *res, const igraph_vector_int_t *pairs, igraph_neimode_t mode, igraph_bool_t loops) { + igraph_integer_t no_of_nodes = igraph_vcount(graph); igraph_lazy_adjlist_t al; igraph_integer_t u, v; igraph_integer_t len_union, len_intersection; @@ -458,6 +458,9 @@ igraph_error_t igraph_similarity_jaccard_pairs(const igraph_t *graph, igraph_vec if (k % 2 != 0) { IGRAPH_ERROR("Number of elements in `pairs' must be even.", IGRAPH_EINVAL); } + if (!igraph_vector_int_isininterval(pairs, 0, no_of_nodes - 1)) { + IGRAPH_ERROR("Invalid vertex ID in pairs.", IGRAPH_EINVVID); + } IGRAPH_CHECK(igraph_vector_resize(res, k / 2)); IGRAPH_CHECK(igraph_lazy_adjlist_init(graph, &al, mode, IGRAPH_NO_LOOPS, IGRAPH_NO_MULTIPLE)); @@ -467,7 +470,7 @@ igraph_error_t igraph_similarity_jaccard_pairs(const igraph_t *graph, igraph_vec /* Add the loop edges */ igraph_vector_bool_t seen; - IGRAPH_VECTOR_BOOL_INIT_FINALLY(&seen, igraph_vcount(graph)); + IGRAPH_VECTOR_BOOL_INIT_FINALLY(&seen, no_of_nodes); for (igraph_integer_t i = 0; i < k; i++) { igraph_integer_t j = VECTOR(*pairs)[i]; diff --git a/src/vendor/cigraph/src/misc/coloring.c b/src/vendor/cigraph/src/misc/coloring.c index 330a3de828f..e96dbd3ba75 100644 --- a/src/vendor/cigraph/src/misc/coloring.c +++ b/src/vendor/cigraph/src/misc/coloring.c @@ -82,7 +82,7 @@ static igraph_error_t igraph_i_vertex_coloring_greedy_cn(const igraph_t *graph, IGRAPH_CHECK(igraph_neighbors(graph, &neighbors, vertex, IGRAPH_ALL)); igraph_integer_t nei_count = igraph_vector_int_size(&neighbors); - /* Colour current vertex by finding smallest available non-0 color. + /* Colour current vertex by finding the smallest available non-0 color. * Note that self-loops are effectively skipped as they merely prevent * the current vertex from being colored with the color value it presently * has, which is 0 (meaning uncolored). */ diff --git a/src/vendor/cigraph/src/misc/mixing.c b/src/vendor/cigraph/src/misc/mixing.c index a60423600f3..ca71c4fb29f 100644 --- a/src/vendor/cigraph/src/misc/mixing.c +++ b/src/vendor/cigraph/src/misc/mixing.c @@ -1,8 +1,7 @@ /* -*- mode: C -*- */ /* IGraph library. - Copyright (C) 2009-2012 Gabor Csardi - 334 Harvard street, Cambridge, MA 02139 USA + Copyright (C) 2009-2023 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 @@ -15,10 +14,7 @@ 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 - + along with this program. If not, see . */ #include "igraph_mixing.h" @@ -94,6 +90,7 @@ * \sa \ref igraph_assortativity() for computing the assortativity * based on continuous vertex values instead of discrete categories. * \ref igraph_modularity() to compute generalized modularity. + * \ref igraph_joint_type_distribution() to obtain the mixing matrix. * * \example examples/simple/igraph_assortativity_nominal.c */ @@ -379,7 +376,9 @@ igraph_error_t igraph_assortativity(const igraph_t *graph, * the number of vertices. * * \sa \ref igraph_assortativity() for the general function - * calculating assortativity for any kind of numeric vertex values. + * calculating assortativity for any kind of numeric vertex values, + * and \ref igraph_joint_degree_distribution() to get the complete + * joint degree distribution. * * \example examples/simple/igraph_assortativity_degree.c */ @@ -436,7 +435,8 @@ igraph_error_t igraph_assortativity_degree(const igraph_t *graph, * * * Note that \c J_ij is similar, but not identical to the joint degree - * \em distribution, which is defined for \em ordered (i, j) degree + * \em distribution, computed by \ref igraph_joint_degree_distribution(), + * which is defined for \em ordered (i, j) degree * pairs even in the undirected case. When considering undirected graphs, the * diagonal of the joint degree distribution is twice that of the joint * degree matrix. @@ -451,6 +451,9 @@ igraph_error_t igraph_assortativity_degree(const igraph_t *graph, * https://doi.org/10.1145/2133803.2330086 * * \param graph A pointer to an initialized graph object. + * \param weights A vector containing the weights of the edges. If passing a + * \c NULL pointer, edges will be assumed to have unit weights, i.e. + * the matrix entries will be connection counts. * \param jdm A pointer to an initialized matrix that will be resized. The values * will be written here. * \param max_out_degree Number of rows in the result, i.e. the largest (out-)degree @@ -459,19 +462,19 @@ igraph_error_t igraph_assortativity_degree(const igraph_t *graph, * \param max_in_degree Number of columns in the result, i.e. the largest (in-)degree * to consider. If negative, the largest (in-)degree of the graph will * be used. - * \param weights A vector containing the weights of the edges. If passing a - * \c NULL pointer, edges will be assumed to have unit weights, i.e. - * the matrix entries will be connection counts. * \return Error code. * + * \sa \ref igraph_joint_degree_distribution() to count ordered vertex pairs instead of + * edges, or to obtain a normalized matrix. + * * Time complexity: O(E), where E is the number of edges in input graph. */ -igraph_error_t igraph_joint_degree_matrix(const igraph_t* graph, - igraph_matrix_t* jdm, - igraph_integer_t max_out_degree, - igraph_integer_t max_in_degree, - const igraph_vector_t* weights) { +igraph_error_t igraph_joint_degree_matrix( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_matrix_t *jdm, + igraph_integer_t max_out_degree, igraph_integer_t max_in_degree) { + igraph_integer_t no_of_nodes = igraph_vcount(graph); igraph_integer_t no_of_edges = igraph_ecount(graph); igraph_eit_t eit; @@ -576,3 +579,379 @@ igraph_error_t igraph_joint_degree_matrix(const igraph_t* graph, return IGRAPH_SUCCESS; } + +/** + * Common implementation for igraph_joint_type_distribution() and igraph_joint_degree_distribution() + * + * For the max_from/to_type parameters, negative values mean "automatic". These are used + * only with igraph_joint_degree_distribution(). + * + * check_types controls whether types should be validated to be non-negative. Validation + * is only necessary with igraph_joint_type_distribution() but not with igraph_joint_degree_distribution(). + * + * directed_neighbors must NOT be true when the graph is undirected. + */ +static igraph_error_t mixing_matrix( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_matrix_t *p, + const igraph_vector_int_t *from_types, const igraph_vector_int_t *to_types, + igraph_bool_t directed_neighbors, igraph_bool_t normalized, + igraph_integer_t max_from_type, igraph_integer_t max_to_type, + igraph_bool_t check_types) { + + igraph_integer_t no_of_nodes = igraph_vcount(graph); + igraph_integer_t no_of_edges = igraph_ecount(graph); + igraph_integer_t nrow, ncol; + igraph_real_t sum; + igraph_bool_t negative_weight; + + if (igraph_vector_int_size(from_types) != no_of_nodes) { + IGRAPH_ERROR("Length of 'from' type vector must agree with vertex count.", IGRAPH_EINVAL); + } + + if (igraph_vector_int_size(to_types) != no_of_nodes) { + IGRAPH_ERROR("Length of 'to' type vector must agree with vertex count.", IGRAPH_EINVAL); + } + + if (weights && igraph_vector_size(weights) != no_of_edges) { + IGRAPH_ERRORF("Weight vector length (%" IGRAPH_PRId ") does not match number of edges (%" IGRAPH_PRId ").", + IGRAPH_EINVAL, + igraph_vector_size(weights), no_of_edges); + } + + if (max_from_type < 0) { + if (no_of_nodes == 0) { + nrow = 0; + } else { + nrow = igraph_vector_int_max(from_types) + 1; + } + } else { + nrow = max_from_type + 1; + } + + if (max_to_type < 0) { + if (no_of_nodes == 0) { + ncol = 0; + } else if (to_types == from_types) { + /* Avoid computing the maximum again if target vertex types + * are the same as source vertex types. */ + ncol = nrow; + } else { + ncol = igraph_vector_int_max(to_types) + 1; + } + } else { + ncol = max_to_type + 1; + } + + if (check_types && no_of_nodes > 0) { + igraph_integer_t min; + + min = igraph_vector_int_min(from_types); + if (min < 0) { + IGRAPH_ERROR("Invalid source vertex type.", IGRAPH_EINVAL); + } + + if (to_types != from_types) { + min = igraph_vector_int_min(from_types); + if (min < 0) { + IGRAPH_ERROR("Invalid target vertex type.", IGRAPH_EINVAL); + } + } + } + + IGRAPH_CHECK(igraph_matrix_resize(p, nrow, ncol)); + igraph_matrix_null(p); + + sum = 0; + negative_weight = false; + for (igraph_integer_t eid=0; eid < no_of_edges; eid++) { + igraph_integer_t from = IGRAPH_FROM(graph, eid); + igraph_integer_t to = IGRAPH_TO(graph, eid); + igraph_integer_t from_type = VECTOR(*from_types)[from]; + igraph_integer_t to_type = VECTOR(*to_types)[to]; + igraph_real_t w = weights ? VECTOR(*weights)[eid] : 1; + + if (from_type >= nrow || to_type >= ncol) { + continue; + } + + MATRIX(*p, from_type, to_type) += w; + sum += w; + + if (! directed_neighbors) { + MATRIX(*p, to_type, from_type) += w; + sum += w; + } + + if (w < 0) { + negative_weight = true; + } + } + + if (normalized) { + if (negative_weight) { + /* When some edge weights are negative, they cannot be interpreted as sampling weights, + * and the sum of weights may be zero, potentially leading to Inf/NaN results. */ + IGRAPH_WARNING("Negative edge weights are present. Normalization may not be meaningful."); + } + if (no_of_edges > 0) { + /* Scale only when there are some edges, thus 'sum' can be non-zero. */ + igraph_matrix_scale(p, 1.0 / sum); + } + } + + return IGRAPH_SUCCESS; +} + + +/** + * \function igraph_joint_degree_distribution + * \brief The joint degree distribution of a graph. + * + * \experimental + * + * Computes the joint degree distribution \c P_ij of a graph, used in the + * study of degree correlations. \c P_ij is the probability that a randomly + * chosen ordered pair of \em connected vertices have degrees \c i and \c j. + * + * + * In directed graphs, directionally connected u -> v pairs + * are considered. The joint degree distribution of an undirected graph is the + * same as that of the corresponding directed graph in which all connection are + * bidirectional, assuming that \p from_mode is \c IGRAPH_OUT, \p to_mode is + * \c IGRAPH_IN and \p directed_neighbors is true. + * + * + * When \p normalized is false, sum_ij P_ij gives the total + * number of connections in a directed graph, or twice that value in an + * undirected graph. The sum is taken over ordered (i,j) degree + * pairs. + * + * + * The joint degree distribution relates to other concepts used in the study of + * degree correlations. If \c P_ij is normalized then the degree correlation + * function k_nn(k) is obtained as + * + * + * k_nn(k) = (sum_j j P_kj) / (sum_j P_kj). + * + * + * The non-normalized degree assortativity is obtained as + * + * + * a = sum_ij i j (P_ij - q_i r_j), + * + * + * where q_i = sum_k P_ik and r_j = sum_k P_kj. + * + * + * Note that the joint degree distribution \c P_ij is similar, but not identical + * to the joint degree matrix \c J_ij computed by \ref igraph_joint_degree_matrix(). + * If the graph is undirected, then the diagonal entries of an unnormalized \c P_ij + * are double that of \c J_ij, as any undirected connection between same-degree vertices + * is counted in both directions. In contrast to \ref igraph_joint_degree_matrix(), + * this function returns matrices which include the row and column corresponding + * to zero degrees. In directed graphs, this row and column is not necessarily + * zero when \p from_mode is different from \c IGRAPH_OUT or \p to_mode is different + * from \c IGRAPH_IN. + * + * + * References: + * + * + * M. E. J. Newman: Mixing patterns in networks, + * Phys. Rev. E 67, 026126 (2003) + * https://doi.org/10.1103/PhysRevE.67.026126. + * + * \param graph A pointer to an initialized graph object. + * \param weights A vector containing the weights of the edges. If passing a + * \c NULL pointer, edges will be assumed to have unit weights. + * \param p A pointer to an initialized matrix that will be resized. The \c P_ij + * value will be written into p[i,j]. + * \param from_mode How to compute the degree of sources? Can be \c IGRAPH_OUT + * for out-degree, \c IGRAPH_IN for in-degree, or \c IGRAPH_ALL for total degree. + * Ignored in undirected graphs. + * \param to_mode How to compute the degree of sources? Can be \c IGRAPH_OUT + * for out-degree, \c IGRAPH_IN for in-degree, or \c IGRAPH_ALL for total degree. + * Ignored in undirected graphs. + * \param directed_neighbors Whether to consider u -> v connections + * to be directed. Undirected connections are treated as reciprocal directed ones, + * i.e. both u -> v and v -> u will be considered. + * Ignored in undirected graphs. + * \param normalized Whether to normalize the matrix so that entries sum to 1.0. + * If false, matrix entries will be connection counts. Normalization is not + * meaningful if some edge weights are negative. + * \param max_from_degree The largest source vertex degree to consider. If negative, + * the largest source degree will be used. The row count of the result matrix + * is one larger than this value. + * \param max_to_degree The largest target vertex degree to consider. If negative, + * the largest target degree will be used. The column count of the result matrix + * is one larger than this value. + * \return Error code. + * + * \sa \ref igraph_joint_degree_matrix() for computing the joint degree matrix; + * \ref igraph_assortativity_degree() and \ref igraph_assortativity() for + * degree correlations coefficients, and \ref igraph_degree_correlation_vector() + * for the degree correlation function. + * + * Time complexity: O(E), where E is the number of edges in the input graph. + */ +igraph_error_t igraph_joint_degree_distribution( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_matrix_t *p, + igraph_neimode_t from_mode, igraph_neimode_t to_mode, + igraph_bool_t directed_neighbors, + igraph_bool_t normalized, + igraph_integer_t max_from_degree, igraph_integer_t max_to_degree) { + + igraph_integer_t no_of_nodes = igraph_vcount(graph); + igraph_vector_int_t *deg_from, *deg_to, deg_out, deg_in, deg_all; + + /* Make sure directionality parameters are consistent for undirected graphs. */ + if (! igraph_is_directed(graph)) { + from_mode = to_mode = IGRAPH_ALL; + directed_neighbors = false; + } + + igraph_bool_t have_out = from_mode == IGRAPH_OUT || to_mode == IGRAPH_OUT; + igraph_bool_t have_in = from_mode == IGRAPH_IN || to_mode == IGRAPH_IN; + igraph_bool_t have_all = from_mode == IGRAPH_ALL || to_mode == IGRAPH_ALL; + + if (have_out) { + IGRAPH_VECTOR_INT_INIT_FINALLY(°_out, no_of_nodes); + IGRAPH_CHECK(igraph_degree(graph, °_out, igraph_vss_all(), IGRAPH_OUT, /* loops */ true)); + } + + if (have_in) { + IGRAPH_VECTOR_INT_INIT_FINALLY(°_in, no_of_nodes); + IGRAPH_CHECK(igraph_degree(graph, °_in, igraph_vss_all(), IGRAPH_IN, /* loops */ true)); + } + + if (have_all) { + IGRAPH_VECTOR_INT_INIT_FINALLY(°_all, no_of_nodes); + IGRAPH_CHECK(igraph_degree(graph, °_all, igraph_vss_all(), IGRAPH_ALL, /* loops */ true)); + } + + switch (from_mode) { + case IGRAPH_OUT: deg_from = °_out; break; + case IGRAPH_IN: deg_from = °_in; break; + case IGRAPH_ALL: deg_from = °_all; break; + default: + IGRAPH_ERROR("Invalid 'from' degree mode.", IGRAPH_EINVAL); + } + + switch (to_mode) { + case IGRAPH_OUT: deg_to = °_out; break; + case IGRAPH_IN: deg_to = °_in; break; + case IGRAPH_ALL: deg_to = °_all; break; + default: + IGRAPH_ERROR("Invalid 'to' degree mode.", IGRAPH_EINVAL); + } + + IGRAPH_CHECK(mixing_matrix(graph, + weights, p, + deg_from, deg_to, + directed_neighbors, normalized, + max_from_degree, max_to_degree, + /*check_types=*/ false)); + + if (have_all) { + igraph_vector_int_destroy(°_all); + IGRAPH_FINALLY_CLEAN(1); + } + + if (have_in) { + igraph_vector_int_destroy(°_in); + IGRAPH_FINALLY_CLEAN(1); + } + + if (have_out) { + igraph_vector_int_destroy(°_out); + IGRAPH_FINALLY_CLEAN(1); + } + + return IGRAPH_SUCCESS; +} + + +/** + * \function igraph_joint_type_distribution + * \brief Mixing matrix for vertex categories. + * + * \experimental + * + * Computes the mixing matrix M_ij, i.e. the joint distribution of vertex types + * at the endpoints directed of edges. Categories are represented by non-negative integer + * indices, passed in \p from_types and \p to_types. The row and column counts of \p m + * will be one larger than the largest source and target type, respectively. Re-index type + * vectors using \ref igraph_reindex_membership() if they are not contiguous integers, + * to avoid producing a very large matrix. + * + * + * M_ij is proportional to the probability that a randomly chosen ordered pair of vertices + * have types \c i and \c j. + * + * + * When there is a single categorization of vertices, i.e. \p from_types and \p to_types + * are the same, M_ij is related to the modularity (\ref igraph_modularity()) and nominal + * assortativity (\ref igraph_assortativity_nominal()). Let a_i = sum_j M_ij and + * b_j = sum_i M_ij. If M_ij is normalized, i.e. sum_ij M_ij = 1, + * and the types represent membership in vertex partitions, then the modularity of the + * partitioning can be computed as + * + * + * Q = sum_ii M_ii - sum_i a_i b_i + * + * + * The normalized nominal assortativity is + * + * + * Q / (1 - sum_i a_i b_i) + * + * + * \ref igraph_joint_degree_distribution() is a special case of this function, with + * categories consisting vertices of the same degree. + * + * + * References: + * + * + * M. E. J. Newman: Mixing patterns in networks, + * Phys. Rev. E 67, 026126 (2003) + * https://doi.org/10.1103/PhysRevE.67.026126. + * + * \param graph The input graph. + * \param p The mixing matrix M_ij will be stored here. + * \param weights A vector containing the weights of the edges. If passing a + * \c NULL pointer, edges will be assumed to have unit weights. + * \param from_types Vertex types for source vertices. These must be non-negative integers. + * \param to_types Vertex types for target vertices. These must be non-negative integers. + * If \c NULL, it is assumed to be the same as \p from_types. + * \param directed Whether to treat edges are directed. Ignored for undirected graphs. + * \param normalized Whether to normalize the matrix so that entries sum to 1.0. + * If false, matrix entries will be connection counts. Normalization is not + * meaningful if some edge weights are negative. + * \return Error code. + * + * \sa \ref igraph_joint_degree_distribution() to compute the joint distribution + * of vertex degrees; \ref igraph_modularity() to compute the modularity of + * a vertex partitioning; \ref igraph_assortativity_nominal() to compute + * assortativity based on vertex categories. + * + * Time complexity: O(E), where E is the number of edges in the input graph. + */ +igraph_error_t igraph_joint_type_distribution( + const igraph_t *graph, const igraph_vector_t *weights, + igraph_matrix_t *p, + const igraph_vector_int_t *from_types, const igraph_vector_int_t *to_types, + igraph_bool_t directed, igraph_bool_t normalized) { + + IGRAPH_ASSERT(from_types != NULL); + if (to_types == NULL) { + to_types = from_types; + } + if (! igraph_is_directed(graph)) { + directed = false; + } + return mixing_matrix(graph, weights, p, from_types, to_types, directed, normalized, -1, -1, true); +} diff --git a/src/vendor/cigraph/src/operators/add_edge.c b/src/vendor/cigraph/src/operators/add_edge.c index 70a5be54ca8..1d082dee761 100644 --- a/src/vendor/cigraph/src/operators/add_edge.c +++ b/src/vendor/cigraph/src/operators/add_edge.c @@ -55,7 +55,7 @@ igraph_error_t igraph_add_edge(igraph_t *graph, igraph_integer_t from, igraph_in VECTOR(edges)[0] = from; VECTOR(edges)[1] = to; - IGRAPH_CHECK(igraph_add_edges(graph, &edges, 0)); + IGRAPH_CHECK(igraph_add_edges(graph, &edges, NULL)); igraph_vector_int_destroy(&edges); IGRAPH_FINALLY_CLEAN(1); diff --git a/src/vendor/cigraph/src/operators/complementer.c b/src/vendor/cigraph/src/operators/complementer.c index 569617afe20..f6a41c6327a 100644 --- a/src/vendor/cigraph/src/operators/complementer.c +++ b/src/vendor/cigraph/src/operators/complementer.c @@ -96,7 +96,7 @@ igraph_error_t igraph_complementer(igraph_t *res, const igraph_t *graph, igraph_vector_int_destroy(&edges); igraph_vector_int_destroy(&neis); IGRAPH_I_ATTRIBUTE_DESTROY(res); - IGRAPH_I_ATTRIBUTE_COPY(res, graph, /*graph=*/1, /*vertex=*/1, /*edge=*/0); + IGRAPH_I_ATTRIBUTE_COPY(res, graph, /*graph=*/true, /*vertex=*/true, /*edge=*/false); IGRAPH_FINALLY_CLEAN(2); return IGRAPH_SUCCESS; } diff --git a/src/vendor/cigraph/src/operators/connect_neighborhood.c b/src/vendor/cigraph/src/operators/connect_neighborhood.c index a15465ec8b4..ce56ffe5735 100644 --- a/src/vendor/cigraph/src/operators/connect_neighborhood.c +++ b/src/vendor/cigraph/src/operators/connect_neighborhood.c @@ -224,8 +224,8 @@ igraph_error_t igraph_graph_power(const igraph_t *graph, igraph_t *res, return IGRAPH_SUCCESS; } - /* Initialize res with a copy of the graph, but with with multi-edges and self-loops removed. - * Also convert the graph to udirected if this is requested. */ + /* Initialize res with a copy of the graph, but with multi-edges and self-loops removed. + * Also convert the graph to undirected if this is requested. */ IGRAPH_CHECK(igraph_adjlist_init(graph, &al, mode, IGRAPH_NO_LOOPS, IGRAPH_NO_MULTIPLE)); IGRAPH_FINALLY(igraph_adjlist_destroy, &al); diff --git a/src/vendor/cigraph/src/operators/disjoint_union.c b/src/vendor/cigraph/src/operators/disjoint_union.c index c8cedb8394b..3ec960d9d9c 100644 --- a/src/vendor/cigraph/src/operators/disjoint_union.c +++ b/src/vendor/cigraph/src/operators/disjoint_union.c @@ -100,7 +100,7 @@ igraph_error_t igraph_disjoint_union(igraph_t *res, const igraph_t *left, /** * \function igraph_disjoint_union_many - * \brief The disjint union of many graphs. + * \brief The disjoint union of many graphs. * * First the vertices in the graphs will be relabeled with new vertex * IDs to have pairwise disjoint vertex ID sets and then the union of diff --git a/src/vendor/cigraph/src/operators/intersection.c b/src/vendor/cigraph/src/operators/intersection.c index 9e5a9aeda68..3ccd4b0c82a 100644 --- a/src/vendor/cigraph/src/operators/intersection.c +++ b/src/vendor/cigraph/src/operators/intersection.c @@ -217,10 +217,10 @@ igraph_error_t igraph_intersection_many( /* OK, now remove all elements from the tail(s) that are bigger than the smallest tail element. */ - for (j = 0, allsame = 1; j < no_of_graphs; j++) { + for (j = 0, allsame = true; j < no_of_graphs; j++) { igraph_integer_t from = -1, to = -1; igraph_vector_int_t *order = igraph_vector_int_list_get_ptr(&order_vects, j); - while (1) { + while (true) { igraph_integer_t edge = igraph_vector_int_tail(order); igraph_vector_int_t *ev = igraph_vector_int_list_get_ptr(&edge_vects, j); from = VECTOR(*ev)[2 * edge]; @@ -236,7 +236,7 @@ igraph_error_t igraph_intersection_many( } } if (from != tailfrom || to != tailto) { - allsame = 0; + allsame = false; } } @@ -247,7 +247,7 @@ igraph_error_t igraph_intersection_many( IGRAPH_CHECK(igraph_vector_int_push_back(&edges, tailto)); } - /* Drop edges matching the smalles tail elements + /* Drop edges matching the smallest tail elements from the order vectors, build edge maps */ if (allne) { for (j = 0; j < no_of_graphs; j++) { diff --git a/src/vendor/cigraph/src/operators/reverse.c b/src/vendor/cigraph/src/operators/reverse.c index 6b6348498dc..ff1c011b9bd 100644 --- a/src/vendor/cigraph/src/operators/reverse.c +++ b/src/vendor/cigraph/src/operators/reverse.c @@ -35,7 +35,7 @@ * \function igraph_reverse_edges * \brief Reverses some edges of a directed graph. * - * This functon reverses some edges of a directed graph. The modification is done in place. + * This function reverses some edges of a directed graph. The modification is done in place. * All attributes, as well as the ordering of edges and vertices are preserved. * * diff --git a/src/vendor/cigraph/src/paths/simple_paths.c b/src/vendor/cigraph/src/paths/simple_paths.c index b8a7998357c..13837750a2a 100644 --- a/src/vendor/cigraph/src/paths/simple_paths.c +++ b/src/vendor/cigraph/src/paths/simple_paths.c @@ -73,7 +73,7 @@ igraph_error_t igraph_get_all_simple_paths(const igraph_t *graph, in order to be appendable to other vectors */ igraph_vector_bool_t markto, added; igraph_vector_int_t nptr; - int iteration = 0; + int iter = 0; if (from < 0 || from >= no_nodes) { IGRAPH_ERROR("Index of source vertex is out of range.", IGRAPH_EINVVID); @@ -120,10 +120,6 @@ igraph_error_t igraph_get_all_simple_paths(const igraph_t *graph, n = igraph_vector_int_size(neis); - if (iteration == 0) { - IGRAPH_ALLOW_INTERRUPTION(); - } - within_dist = (curdist < cutoff || cutoff < 0); if (within_dist) { /* Search for a neighbor that was not yet visited */ @@ -152,10 +148,7 @@ igraph_error_t igraph_get_all_simple_paths(const igraph_t *graph, VECTOR(nptr)[up] = 0; } - iteration++; - if (iteration >= 10000) { - iteration = 0; - } + IGRAPH_ALLOW_INTERRUPTION_LIMITED(iter, 1 << 13); } igraph_vector_int_destroy(&nptr); diff --git a/src/vendor/cigraph/src/properties/basic_properties.c b/src/vendor/cigraph/src/properties/basic_properties.c index 27da08365aa..409dac12ea1 100644 --- a/src/vendor/cigraph/src/properties/basic_properties.c +++ b/src/vendor/cigraph/src/properties/basic_properties.c @@ -40,17 +40,18 @@ * The density of a graph is simply the ratio of the actual number of its * edges and the largest possible number of edges it could have. * The maximum number of edges depends on interpretation: are vertices - * allowed to have a connected to themselves? This is controlled by the + * allowed to have a connection to themselves? This is controlled by the * \p loops parameter. * * * Note that density is ill-defined for graphs which have multiple edges * between some pairs of vertices. Consider calling \ref igraph_simplify() - * on such graphs. + * on such graphs. This function does not check whether the graph has + * parallel edges. The result it returns for such graphs is not meaningful. * * \param graph The input graph object. * \param res Pointer to a real number, the result will be stored - * here. + * here. It must not have parallel edges. * \param loops Logical constant, whether to include self-loops in the * calculation. If this constant is \c true then * loop edges are thought to be possible in the graph (this does not diff --git a/src/vendor/cigraph/src/properties/degrees.c b/src/vendor/cigraph/src/properties/degrees.c index 18809097c52..200134c1c3e 100644 --- a/src/vendor/cigraph/src/properties/degrees.c +++ b/src/vendor/cigraph/src/properties/degrees.c @@ -2,7 +2,7 @@ /* vim:set ts=4 sw=4 sts=4 et: */ /* IGraph library. - Copyright (C) 2005-2021 The igraph development team + Copyright (C) 2005-2023 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 @@ -15,10 +15,7 @@ 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 - + along with this program. If not, see . */ #include "igraph_structural.h" @@ -374,8 +371,9 @@ igraph_error_t igraph_avg_nearest_neighbor_degree(const igraph_t *graph, * ones. * * - * If P_ij is the joint degree distribution of the graph, then - * k_nn(k) = sum_k j P_kj. + * If P_ij is the joint degree distribution of the graph, computable with + * \ref igraph_joint_degree_distribution(), then + * k_nn(k) = (sum_j j P_kj) / (sum_j P_kj). * * * The function \ref igraph_avg_nearest_neighbor_degree(), whose main purpose is to @@ -406,12 +404,12 @@ igraph_error_t igraph_avg_nearest_neighbor_degree(const igraph_t *graph, * https://dx.doi.org/10.1073/pnas.0400087101 * * \param graph The input graph. + * \param weights An optional weight vector. If not \c NULL, weighted averages will be computed. * \param knnk An initialized vector, the result will be written here. * knnk[d] will contain the mean degree of vertices connected to * by vertices of degree \c d. Note that in contrast to * \ref igraph_avg_nearest_neighbor_degree(), d=0 is also * included. - * \param weights An optional weight vector. If not \c NULL, weighted averages will be computed. * \param from_mode How to compute the degree of sources? Can be \c IGRAPH_OUT * for out-degree, \c IGRAPH_IN for in-degree, or \c IGRAPH_ALL for total degree. * Ignored in undirected graphs. @@ -422,17 +420,20 @@ igraph_error_t igraph_avg_nearest_neighbor_degree(const igraph_t *graph, * to be directed. Undirected connections are treated as reciprocal directed ones, * i.e. both u -> v and v -> u will be considered. * Ignored in undirected graphs. - * \returns Error code. + * \return Error code. * - * \sa \ref igraph_avg_nearest_neighbor_degree() for computing the average neighbour degree of - * a set of vertices. + * \sa \ref igraph_avg_nearest_neighbor_degree() for computing the average neighbour + * degree of a set of vertices, \ref igraph_joint_degree_distribution() to get the + * complete joint degree distribution, and \ref igraph_assortativity_degree() + * to compute the degree assortativity. * * Time complexity: O(|E| + |V|) */ igraph_error_t igraph_degree_correlation_vector( - const igraph_t *graph, igraph_vector_t *knnk, const igraph_vector_t *weights, - igraph_neimode_t from_mode, igraph_neimode_t to_mode, - igraph_bool_t directed_neighbors) { + const igraph_t *graph, const igraph_vector_t *weights, + igraph_vector_t *knnk, + igraph_neimode_t from_mode, igraph_neimode_t to_mode, + igraph_bool_t directed_neighbors) { igraph_integer_t no_of_nodes = igraph_vcount(graph); igraph_integer_t no_of_edges = igraph_ecount(graph); @@ -440,6 +441,12 @@ igraph_error_t igraph_degree_correlation_vector( igraph_vector_t weight_sums; igraph_vector_int_t *deg_from, *deg_to, deg_out, deg_in, deg_all; + if (weights && igraph_vector_size(weights) != no_of_edges) { + IGRAPH_ERRORF("Weight vector length (%" IGRAPH_PRId ") does not match number of edges (%" IGRAPH_PRId ").", + IGRAPH_EINVAL, + igraph_vector_size(weights), no_of_edges); + } + if (! igraph_is_directed(graph)) { from_mode = to_mode = IGRAPH_ALL; directed_neighbors = false; @@ -469,7 +476,7 @@ igraph_error_t igraph_degree_correlation_vector( case IGRAPH_IN: deg_from = °_in; break; case IGRAPH_ALL: deg_from = °_all; break; default: - IGRAPH_ERROR("Invalid mode.", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid 'from' mode.", IGRAPH_EINVAL); } switch (to_mode) { @@ -477,7 +484,7 @@ igraph_error_t igraph_degree_correlation_vector( case IGRAPH_IN: deg_to = °_in; break; case IGRAPH_ALL: deg_to = °_all; break; default: - IGRAPH_ERROR("Invalid mode.", IGRAPH_EINVAL); + IGRAPH_ERROR("Invalid 'to' mode.", IGRAPH_EINVAL); } maxdeg = no_of_edges > 0 ? igraph_vector_int_max(deg_from) : 0; diff --git a/src/vendor/cigraph/vendor/cs/CMakeLists.txt b/src/vendor/cigraph/vendor/cs/CMakeLists.txt new file mode 100644 index 00000000000..bef000d88c6 --- /dev/null +++ b/src/vendor/cigraph/vendor/cs/CMakeLists.txt @@ -0,0 +1,93 @@ +# Declare the files needed to compile our vendored CXSparse copy +add_library( + cxsparse_vendored + OBJECT + EXCLUDE_FROM_ALL + cs_add.c + cs_amd.c + cs_chol.c + cs_cholsol.c + cs_compress.c + cs_counts.c + cs_cumsum.c + cs_dfs.c + cs_dmperm.c + cs_droptol.c + cs_dropzeros.c + cs_dupl.c + cs_entry.c + cs_ereach.c + cs_etree.c + cs_fkeep.c + cs_gaxpy.c + cs_happly.c + cs_house.c + cs_ipvec.c + cs_leaf.c + cs_load.c + cs_lsolve.c + cs_ltsolve.c + cs_lu.c + cs_lusol.c + cs_malloc.c + cs_maxtrans.c + cs_multiply.c + cs_norm.c + cs_permute.c + cs_pinv.c + cs_post.c + cs_pvec.c + cs_qr.c + cs_qrsol.c + cs_randperm.c + cs_reach.c + cs_scatter.c + cs_scc.c + cs_schol.c + cs_spsolve.c + cs_sqr.c + cs_symperm.c + cs_tdfs.c + cs_transpose.c + cs_updown.c + cs_usolve.c + cs_util.c + cs_utsolve.c + # the following files are not needed - they contain no symbols + # cs_print.c +) + +target_include_directories( + cxsparse_vendored + PRIVATE + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include +) + +if (BUILD_SHARED_LIBS) + set_property(TARGET cxsparse_vendored PROPERTY POSITION_INDEPENDENT_CODE ON) +endif() + +# Disable complex number support for CXSparse because: +# - It is necessary to compile with MSVC +# - igraph does not need complex number support from CXSparse on any platform +target_compile_definitions(cxsparse_vendored PUBLIC NCOMPLEX) + +# Since these are included as object files, they should call the +# function as is (without a visibility specification) +target_compile_definitions(cxsparse_vendored PRIVATE IGRAPH_STATIC) + +use_all_warnings(cxsparse_vendored) + +if (MSVC) + target_compile_options( + cxsparse_vendored PRIVATE + /wd4100 + ) # disable unreferenced parameter warning +else() + target_compile_options( + cxsparse_vendored PRIVATE + $<$:-Wno-unused-variable> + ) +endif() + diff --git a/src/vendor/cigraph/vendor/cs/License.txt b/src/vendor/cigraph/vendor/cs/License.txt new file mode 100644 index 00000000000..df6f4258d41 --- /dev/null +++ b/src/vendor/cigraph/vendor/cs/License.txt @@ -0,0 +1,19 @@ +CXSparse: a Concise Sparse matrix package - Extended. +Copyright (c) 2006, Timothy A. Davis. +http://www.suitesparse.com + +-------------------------------------------------------------------------------- + +CXSparse is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +CXSparse 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this Module; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/src/vendor/cigraph/vendor/cs/cs.h b/src/vendor/cigraph/vendor/cs/cs.h new file mode 100644 index 00000000000..a505ca55aa6 --- /dev/null +++ b/src/vendor/cigraph/vendor/cs/cs.h @@ -0,0 +1,315 @@ +/* This is a MODIFIED version of the original CXSparse/Include/cs.h file from + * SuiteSparse 5.12.0 (CXSparse version 3.2.0). The modifications are outlined + * here: + * + * - Dependency on SuiteSparse_long was removed + * - CXSparse is configured to use igraph_integer_t as cs_long_t + * - CXSparse function prefix is set to cs_igraph instead of cs_igraph + * - Unneeded CXSparse function variants are removed + * + * The remaining comments below are from the original cs.h header */ + +/* ========================================================================== */ +/* CXSparse/Include/cs.h file */ +/* ========================================================================== */ + +/* This is the CXSparse/Include/cs.h file. It has the same name (cs.h) as + the CSparse/Include/cs.h file. The 'make install' for SuiteSparse installs + CXSparse, and this file, instead of CSparse. The two packages have the same + cs.h include filename, because CXSparse is a superset of CSparse. Any user + program that uses CSparse can rely on CXSparse instead, with no change to the + user code. The #include "cs.h" line will work for both versions, in user + code, and the function names and user-visible typedefs from CSparse all + appear in CXSparse. For experimenting and changing the package itself, I + recommend using CSparse since it's simpler and easier to modify. For + using the package in production codes, I recommend CXSparse since it has + more features (support for complex matrices, and both int and long + versions). + */ + +/* ========================================================================== */ + +#ifndef _CXS_H +#define _CXS_H +#include +#include +#include +#include +#ifdef MATLAB_MEX_FILE +#include "mex.h" +#endif + +#include "igraph_types.h" + +#ifdef __cplusplus +#ifndef NCOMPLEX +#include +typedef std::complex cs_complex_t ; +#endif +extern "C" { +#else +#ifndef NCOMPLEX +#include +#define cs_complex_t double _Complex +#endif +#endif + +#define CS_VER 3 /* CXSparse Version */ +#define CS_SUBVER 2 +#define CS_SUBSUB 0 +#define CS_DATE "Sept 12, 2017" /* CSparse release date */ +#define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006-2016" +#define CXSPARSE + +#define cs_long_t igraph_integer_t +#define cs_long_t_id "%" IGRAPH_PRId +#define cs_long_t_max IGRAPH_INTEGER_MAX + +/* -------------------------------------------------------------------------- */ +/* double/cs_long_t version of CXSparse */ +/* -------------------------------------------------------------------------- */ + +/* --- primary CSparse routines and data structures ------------------------- */ + +typedef struct cs_igraph_sparse /* matrix in compressed-column or triplet form */ +{ + cs_long_t nzmax ; /* maximum number of entries */ + cs_long_t m ; /* number of rows */ + cs_long_t n ; /* number of columns */ + cs_long_t *p ; /* column pointers (size n+1) or col indlces (size nzmax) */ + cs_long_t *i ; /* row indices, size nzmax */ + double *x ; /* numerical values, size nzmax */ + cs_long_t nz ; /* # of entries in triplet matrix, -1 for compressed-col */ +} cs_igraph ; + +cs_igraph *cs_igraph_add (const cs_igraph *A, const cs_igraph *B, double alpha, double beta) ; +cs_long_t cs_igraph_cholsol (cs_long_t order, const cs_igraph *A, double *b) ; +cs_long_t cs_igraph_dupl (cs_igraph *A) ; +cs_long_t cs_igraph_entry (cs_igraph *T, cs_long_t i, cs_long_t j, double x) ; +cs_long_t cs_igraph_lusol (cs_long_t order, const cs_igraph *A, double *b, double tol) ; +cs_long_t cs_igraph_gaxpy (const cs_igraph *A, const double *x, double *y) ; +cs_igraph *cs_igraph_multiply (const cs_igraph *A, const cs_igraph *B) ; +cs_long_t cs_igraph_qrsol (cs_long_t order, const cs_igraph *A, double *b) ; +cs_igraph *cs_igraph_transpose (const cs_igraph *A, cs_long_t values) ; +cs_igraph *cs_igraph_compress (const cs_igraph *T) ; +double cs_igraph_norm (const cs_igraph *A) ; +/*cs_long_t cs_igraph_print (const cs_igraph *A, cs_long_t brief) ;*/ +cs_igraph *cs_igraph_load (FILE *f) ; + +/* utilities */ +void *cs_igraph_calloc (cs_long_t n, size_t size) ; +void *cs_igraph_free (void *p) ; +void *cs_igraph_realloc (void *p, cs_long_t n, size_t size, cs_long_t *ok) ; +cs_igraph *cs_igraph_spalloc (cs_long_t m, cs_long_t n, cs_long_t nzmax, cs_long_t values, + cs_long_t t) ; +cs_igraph *cs_igraph_spfree (cs_igraph *A) ; +cs_long_t cs_igraph_sprealloc (cs_igraph *A, cs_long_t nzmax) ; +void *cs_igraph_malloc (cs_long_t n, size_t size) ; + +/* --- secondary CSparse routines and data structures ----------------------- */ + +typedef struct cs_igraph_symbolic /* symbolic Cholesky, LU, or QR analysis */ +{ + cs_long_t *pinv ; /* inverse row perm. for QR, fill red. perm for Chol */ + cs_long_t *q ; /* fill-reducing column permutation for LU and QR */ + cs_long_t *parent ; /* elimination tree for Cholesky and QR */ + cs_long_t *cp ; /* column pointers for Cholesky, row counts for QR */ + cs_long_t *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */ + cs_long_t m2 ; /* # of rows for QR, after adding fictitious rows */ + double lnz ; /* # entries in L for LU or Cholesky; in V for QR */ + double unz ; /* # entries in U for LU; in R for QR */ +} cs_igraphs ; + +typedef struct cs_igraph_numeric /* numeric Cholesky, LU, or QR factorization */ +{ + cs_igraph *L ; /* L for LU and Cholesky, V for QR */ + cs_igraph *U ; /* U for LU, r for QR, not used for Cholesky */ + cs_long_t *pinv ; /* partial pivoting for LU */ + double *B ; /* beta [0..n-1] for QR */ +} cs_igraphn ; + +typedef struct cs_igraph_dmperm_results /* cs_igraph_dmperm or cs_igraph_scc output */ +{ + cs_long_t *p ; /* size m, row permutation */ + cs_long_t *q ; /* size n, column permutation */ + cs_long_t *r ; /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */ + cs_long_t *s ; /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */ + cs_long_t nb ; /* # of blocks in fine dmperm decomposition */ + cs_long_t rr [5] ; /* coarse row decomposition */ + cs_long_t cc [5] ; /* coarse column decomposition */ +} cs_igraphd ; + +cs_long_t *cs_igraph_amd (cs_long_t order, const cs_igraph *A) ; +cs_igraphn *cs_igraph_chol (const cs_igraph *A, const cs_igraphs *S) ; +cs_igraphd *cs_igraph_dmperm (const cs_igraph *A, cs_long_t seed) ; +cs_long_t cs_igraph_droptol (cs_igraph *A, double tol) ; +cs_long_t cs_igraph_dropzeros (cs_igraph *A) ; +cs_long_t cs_igraph_happly (const cs_igraph *V, cs_long_t i, double beta, double *x) ; +cs_long_t cs_igraph_ipvec (const cs_long_t *p, const double *b, double *x, cs_long_t n) ; +cs_long_t cs_igraph_lsolve (const cs_igraph *L, double *x) ; +cs_long_t cs_igraph_ltsolve (const cs_igraph *L, double *x) ; +cs_igraphn *cs_igraph_lu (const cs_igraph *A, const cs_igraphs *S, double tol) ; +cs_igraph *cs_igraph_permute (const cs_igraph *A, const cs_long_t *pinv, const cs_long_t *q, + cs_long_t values) ; +cs_long_t *cs_igraph_pinv (const cs_long_t *p, cs_long_t n) ; +cs_long_t cs_igraph_pvec (const cs_long_t *p, const double *b, double *x, cs_long_t n) ; +cs_igraphn *cs_igraph_qr (const cs_igraph *A, const cs_igraphs *S) ; +cs_igraphs *cs_igraph_schol (cs_long_t order, const cs_igraph *A) ; +cs_igraphs *cs_igraph_sqr (cs_long_t order, const cs_igraph *A, cs_long_t qr) ; +cs_igraph *cs_igraph_symperm (const cs_igraph *A, const cs_long_t *pinv, cs_long_t values) ; +cs_long_t cs_igraph_usolve (const cs_igraph *U, double *x) ; +cs_long_t cs_igraph_utsolve (const cs_igraph *U, double *x) ; +cs_long_t cs_igraph_updown (cs_igraph *L, cs_long_t sigma, const cs_igraph *C, + const cs_long_t *parent) ; + +/* utilities */ +cs_igraphs *cs_igraph_sfree (cs_igraphs *S) ; +cs_igraphn *cs_igraph_nfree (cs_igraphn *N) ; +cs_igraphd *cs_igraph_dfree (cs_igraphd *D) ; + +/* --- tertiary CSparse routines -------------------------------------------- */ + +cs_long_t *cs_igraph_counts (const cs_igraph *A, const cs_long_t *parent, + const cs_long_t *post, cs_long_t ata) ; +double cs_igraph_cumsum (cs_long_t *p, cs_long_t *c, cs_long_t n) ; +cs_long_t cs_igraph_dfs (cs_long_t j, cs_igraph *G, cs_long_t top, cs_long_t *xi, + cs_long_t *pstack, const cs_long_t *pinv) ; +cs_long_t *cs_igraph_etree (const cs_igraph *A, cs_long_t ata) ; +cs_long_t cs_igraph_fkeep (cs_igraph *A, + cs_long_t (*fkeep) (cs_long_t, cs_long_t, double, void *), void *other) ; +double cs_igraph_house (double *x, double *beta, cs_long_t n) ; +cs_long_t *cs_igraph_maxtrans (const cs_igraph *A, cs_long_t seed) ; +cs_long_t *cs_igraph_post (const cs_long_t *parent, cs_long_t n) ; +cs_igraphd *cs_igraph_scc (cs_igraph *A) ; +cs_long_t cs_igraph_scatter (const cs_igraph *A, cs_long_t j, double beta, cs_long_t *w, + double *x, cs_long_t mark,cs_igraph *C, cs_long_t nz) ; +cs_long_t cs_igraph_tdfs (cs_long_t j, cs_long_t k, cs_long_t *head, const cs_long_t *next, + cs_long_t *post, cs_long_t *stack) ; +cs_long_t cs_igraph_leaf (cs_long_t i, cs_long_t j, const cs_long_t *first, + cs_long_t *maxfirst, cs_long_t *prevleaf, cs_long_t *ancestor, cs_long_t *jleaf) ; +cs_long_t cs_igraph_reach (cs_igraph *G, const cs_igraph *B, cs_long_t k, cs_long_t *xi, + const cs_long_t *pinv) ; +cs_long_t cs_igraph_spsolve (cs_igraph *L, const cs_igraph *B, cs_long_t k, cs_long_t *xi, + double *x, const cs_long_t *pinv, cs_long_t lo) ; +cs_long_t cs_igraph_ereach (const cs_igraph *A, cs_long_t k, const cs_long_t *parent, + cs_long_t *s, cs_long_t *w) ; +cs_long_t *cs_igraph_randperm (cs_long_t n, cs_long_t seed) ; + +/* utilities */ +cs_igraphd *cs_igraph_dalloc (cs_long_t m, cs_long_t n) ; +cs_igraph *cs_igraph_done (cs_igraph *C, void *w, void *x, cs_long_t ok) ; +cs_long_t *cs_igraph_idone (cs_long_t *p, cs_igraph *C, void *w, cs_long_t ok) ; +cs_igraphn *cs_igraph_ndone (cs_igraphn *N, cs_igraph *C, void *w, void *x, cs_long_t ok) ; +cs_igraphd *cs_igraph_ddone (cs_igraphd *D, cs_igraph *C, void *w, cs_long_t ok) ; + +/* -------------------------------------------------------------------------- */ +/* Macros for constructing each version of CSparse */ +/* -------------------------------------------------------------------------- */ + +#define CS_INT cs_long_t +#define CS_INT_MAX cs_long_t_max +#define CS_ID cs_long_t_id +#define CS_ENTRY double +#define CS_NAME(nm) cs_igraph ## nm +#define cs cs_igraph + +#define CS_REAL(x) (x) +#define CS_IMAG(x) (0.) +#define CS_CONJ(x) (x) +#define CS_ABS(x) fabs(x) + +#define CS_MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define CS_MIN(a,b) (((a) < (b)) ? (a) : (b)) +#define CS_FLIP(i) (-(i)-2) +#define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i)) +#define CS_MARKED(w,j) (w [j] < 0) +#define CS_MARK(w,j) { w [j] = CS_FLIP (w [j]) ; } +#define CS_CSC(A) (A && (A->nz == -1)) +#define CS_TRIPLET(A) (A && (A->nz >= 0)) + +/* --- primary CSparse routines and data structures ------------------------- */ + +#define cs_add CS_NAME (_add) +#define cs_cholsol CS_NAME (_cholsol) +#define cs_dupl CS_NAME (_dupl) +#define cs_entry CS_NAME (_entry) +#define cs_lusol CS_NAME (_lusol) +#define cs_gaxpy CS_NAME (_gaxpy) +#define cs_multiply CS_NAME (_multiply) +#define cs_qrsol CS_NAME (_qrsol) +#define cs_transpose CS_NAME (_transpose) +#define cs_compress CS_NAME (_compress) +#define cs_norm CS_NAME (_norm) +/*#define cs_print CS_NAME (_print)*/ +#define cs_load CS_NAME (_load) + +/* utilities */ +#define cs_calloc CS_NAME (_calloc) +#define cs_free CS_NAME (_free) +#define cs_realloc CS_NAME (_realloc) +#define cs_spalloc CS_NAME (_spalloc) +#define cs_spfree CS_NAME (_spfree) +#define cs_sprealloc CS_NAME (_sprealloc) +#define cs_malloc CS_NAME (_malloc) + +/* --- secondary CSparse routines and data structures ----------------------- */ +#define css CS_NAME (s) +#define csn CS_NAME (n) +#define csd CS_NAME (d) + +#define cs_amd CS_NAME (_amd) +#define cs_chol CS_NAME (_chol) +#define cs_dmperm CS_NAME (_dmperm) +#define cs_droptol CS_NAME (_droptol) +#define cs_dropzeros CS_NAME (_dropzeros) +#define cs_happly CS_NAME (_happly) +#define cs_ipvec CS_NAME (_ipvec) +#define cs_lsolve CS_NAME (_lsolve) +#define cs_ltsolve CS_NAME (_ltsolve) +#define cs_lu CS_NAME (_lu) +#define cs_permute CS_NAME (_permute) +#define cs_pinv CS_NAME (_pinv) +#define cs_pvec CS_NAME (_pvec) +#define cs_qr CS_NAME (_qr) +#define cs_schol CS_NAME (_schol) +#define cs_sqr CS_NAME (_sqr) +#define cs_symperm CS_NAME (_symperm) +#define cs_usolve CS_NAME (_usolve) +#define cs_utsolve CS_NAME (_utsolve) +#define cs_updown CS_NAME (_updown) + +/* utilities */ +#define cs_sfree CS_NAME (_sfree) +#define cs_nfree CS_NAME (_nfree) +#define cs_dfree CS_NAME (_dfree) + +/* --- tertiary CSparse routines -------------------------------------------- */ +#define cs_counts CS_NAME (_counts) +#define cs_cumsum CS_NAME (_cumsum) +#define cs_dfs CS_NAME (_dfs) +#define cs_etree CS_NAME (_etree) +#define cs_fkeep CS_NAME (_fkeep) +#define cs_house CS_NAME (_house) +#define cs_invmatch CS_NAME (_invmatch) +#define cs_maxtrans CS_NAME (_maxtrans) +#define cs_post CS_NAME (_post) +#define cs_scc CS_NAME (_scc) +#define cs_scatter CS_NAME (_scatter) +#define cs_tdfs CS_NAME (_tdfs) +#define cs_reach CS_NAME (_reach) +#define cs_spsolve CS_NAME (_spsolve) +#define cs_ereach CS_NAME (_ereach) +#define cs_randperm CS_NAME (_randperm) +#define cs_leaf CS_NAME (_leaf) + +/* utilities */ +#define cs_dalloc CS_NAME (_dalloc) +#define cs_done CS_NAME (_done) +#define cs_idone CS_NAME (_idone) +#define cs_ndone CS_NAME (_ndone) +#define cs_ddone CS_NAME (_ddone) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/vendor/cs/cs_add.c b/src/vendor/cigraph/vendor/cs/cs_add.c similarity index 100% rename from src/vendor/cs/cs_add.c rename to src/vendor/cigraph/vendor/cs/cs_add.c diff --git a/src/vendor/cs/cs_amd.c b/src/vendor/cigraph/vendor/cs/cs_amd.c similarity index 100% rename from src/vendor/cs/cs_amd.c rename to src/vendor/cigraph/vendor/cs/cs_amd.c diff --git a/src/vendor/cs/cs_chol.c b/src/vendor/cigraph/vendor/cs/cs_chol.c similarity index 100% rename from src/vendor/cs/cs_chol.c rename to src/vendor/cigraph/vendor/cs/cs_chol.c diff --git a/src/vendor/cs/cs_cholsol.c b/src/vendor/cigraph/vendor/cs/cs_cholsol.c similarity index 100% rename from src/vendor/cs/cs_cholsol.c rename to src/vendor/cigraph/vendor/cs/cs_cholsol.c diff --git a/src/vendor/cs/cs_compress.c b/src/vendor/cigraph/vendor/cs/cs_compress.c similarity index 100% rename from src/vendor/cs/cs_compress.c rename to src/vendor/cigraph/vendor/cs/cs_compress.c diff --git a/src/vendor/cs/cs_counts.c b/src/vendor/cigraph/vendor/cs/cs_counts.c similarity index 100% rename from src/vendor/cs/cs_counts.c rename to src/vendor/cigraph/vendor/cs/cs_counts.c diff --git a/src/vendor/cs/cs_cumsum.c b/src/vendor/cigraph/vendor/cs/cs_cumsum.c similarity index 100% rename from src/vendor/cs/cs_cumsum.c rename to src/vendor/cigraph/vendor/cs/cs_cumsum.c diff --git a/src/vendor/cs/cs_dfs.c b/src/vendor/cigraph/vendor/cs/cs_dfs.c similarity index 100% rename from src/vendor/cs/cs_dfs.c rename to src/vendor/cigraph/vendor/cs/cs_dfs.c diff --git a/src/vendor/cs/cs_dmperm.c b/src/vendor/cigraph/vendor/cs/cs_dmperm.c similarity index 100% rename from src/vendor/cs/cs_dmperm.c rename to src/vendor/cigraph/vendor/cs/cs_dmperm.c diff --git a/src/vendor/cs/cs_droptol.c b/src/vendor/cigraph/vendor/cs/cs_droptol.c similarity index 100% rename from src/vendor/cs/cs_droptol.c rename to src/vendor/cigraph/vendor/cs/cs_droptol.c diff --git a/src/vendor/cs/cs_dropzeros.c b/src/vendor/cigraph/vendor/cs/cs_dropzeros.c similarity index 100% rename from src/vendor/cs/cs_dropzeros.c rename to src/vendor/cigraph/vendor/cs/cs_dropzeros.c diff --git a/src/vendor/cs/cs_dupl.c b/src/vendor/cigraph/vendor/cs/cs_dupl.c similarity index 100% rename from src/vendor/cs/cs_dupl.c rename to src/vendor/cigraph/vendor/cs/cs_dupl.c diff --git a/src/vendor/cs/cs_entry.c b/src/vendor/cigraph/vendor/cs/cs_entry.c similarity index 100% rename from src/vendor/cs/cs_entry.c rename to src/vendor/cigraph/vendor/cs/cs_entry.c diff --git a/src/vendor/cs/cs_ereach.c b/src/vendor/cigraph/vendor/cs/cs_ereach.c similarity index 100% rename from src/vendor/cs/cs_ereach.c rename to src/vendor/cigraph/vendor/cs/cs_ereach.c diff --git a/src/vendor/cs/cs_etree.c b/src/vendor/cigraph/vendor/cs/cs_etree.c similarity index 100% rename from src/vendor/cs/cs_etree.c rename to src/vendor/cigraph/vendor/cs/cs_etree.c diff --git a/src/vendor/cs/cs_fkeep.c b/src/vendor/cigraph/vendor/cs/cs_fkeep.c similarity index 100% rename from src/vendor/cs/cs_fkeep.c rename to src/vendor/cigraph/vendor/cs/cs_fkeep.c diff --git a/src/vendor/cs/cs_gaxpy.c b/src/vendor/cigraph/vendor/cs/cs_gaxpy.c similarity index 100% rename from src/vendor/cs/cs_gaxpy.c rename to src/vendor/cigraph/vendor/cs/cs_gaxpy.c diff --git a/src/vendor/cs/cs_happly.c b/src/vendor/cigraph/vendor/cs/cs_happly.c similarity index 100% rename from src/vendor/cs/cs_happly.c rename to src/vendor/cigraph/vendor/cs/cs_happly.c diff --git a/src/vendor/cs/cs_house.c b/src/vendor/cigraph/vendor/cs/cs_house.c similarity index 100% rename from src/vendor/cs/cs_house.c rename to src/vendor/cigraph/vendor/cs/cs_house.c diff --git a/src/vendor/cs/cs_ipvec.c b/src/vendor/cigraph/vendor/cs/cs_ipvec.c similarity index 100% rename from src/vendor/cs/cs_ipvec.c rename to src/vendor/cigraph/vendor/cs/cs_ipvec.c diff --git a/src/vendor/cs/cs_leaf.c b/src/vendor/cigraph/vendor/cs/cs_leaf.c similarity index 100% rename from src/vendor/cs/cs_leaf.c rename to src/vendor/cigraph/vendor/cs/cs_leaf.c diff --git a/src/vendor/cs/cs_load.c b/src/vendor/cigraph/vendor/cs/cs_load.c similarity index 100% rename from src/vendor/cs/cs_load.c rename to src/vendor/cigraph/vendor/cs/cs_load.c diff --git a/src/vendor/cs/cs_lsolve.c b/src/vendor/cigraph/vendor/cs/cs_lsolve.c similarity index 100% rename from src/vendor/cs/cs_lsolve.c rename to src/vendor/cigraph/vendor/cs/cs_lsolve.c diff --git a/src/vendor/cs/cs_ltsolve.c b/src/vendor/cigraph/vendor/cs/cs_ltsolve.c similarity index 100% rename from src/vendor/cs/cs_ltsolve.c rename to src/vendor/cigraph/vendor/cs/cs_ltsolve.c diff --git a/src/vendor/cs/cs_lu.c b/src/vendor/cigraph/vendor/cs/cs_lu.c similarity index 100% rename from src/vendor/cs/cs_lu.c rename to src/vendor/cigraph/vendor/cs/cs_lu.c diff --git a/src/vendor/cs/cs_lusol.c b/src/vendor/cigraph/vendor/cs/cs_lusol.c similarity index 100% rename from src/vendor/cs/cs_lusol.c rename to src/vendor/cigraph/vendor/cs/cs_lusol.c diff --git a/src/vendor/cs/cs_malloc.c b/src/vendor/cigraph/vendor/cs/cs_malloc.c similarity index 100% rename from src/vendor/cs/cs_malloc.c rename to src/vendor/cigraph/vendor/cs/cs_malloc.c diff --git a/src/vendor/cs/cs_maxtrans.c b/src/vendor/cigraph/vendor/cs/cs_maxtrans.c similarity index 100% rename from src/vendor/cs/cs_maxtrans.c rename to src/vendor/cigraph/vendor/cs/cs_maxtrans.c diff --git a/src/vendor/cs/cs_multiply.c b/src/vendor/cigraph/vendor/cs/cs_multiply.c similarity index 100% rename from src/vendor/cs/cs_multiply.c rename to src/vendor/cigraph/vendor/cs/cs_multiply.c diff --git a/src/vendor/cs/cs_norm.c b/src/vendor/cigraph/vendor/cs/cs_norm.c similarity index 100% rename from src/vendor/cs/cs_norm.c rename to src/vendor/cigraph/vendor/cs/cs_norm.c diff --git a/src/vendor/cs/cs_permute.c b/src/vendor/cigraph/vendor/cs/cs_permute.c similarity index 100% rename from src/vendor/cs/cs_permute.c rename to src/vendor/cigraph/vendor/cs/cs_permute.c diff --git a/src/vendor/cs/cs_pinv.c b/src/vendor/cigraph/vendor/cs/cs_pinv.c similarity index 100% rename from src/vendor/cs/cs_pinv.c rename to src/vendor/cigraph/vendor/cs/cs_pinv.c diff --git a/src/vendor/cs/cs_post.c b/src/vendor/cigraph/vendor/cs/cs_post.c similarity index 100% rename from src/vendor/cs/cs_post.c rename to src/vendor/cigraph/vendor/cs/cs_post.c diff --git a/src/vendor/cs/cs_print.c b/src/vendor/cigraph/vendor/cs/cs_print.c similarity index 100% rename from src/vendor/cs/cs_print.c rename to src/vendor/cigraph/vendor/cs/cs_print.c diff --git a/src/vendor/cs/cs_pvec.c b/src/vendor/cigraph/vendor/cs/cs_pvec.c similarity index 100% rename from src/vendor/cs/cs_pvec.c rename to src/vendor/cigraph/vendor/cs/cs_pvec.c diff --git a/src/vendor/cs/cs_qr.c b/src/vendor/cigraph/vendor/cs/cs_qr.c similarity index 100% rename from src/vendor/cs/cs_qr.c rename to src/vendor/cigraph/vendor/cs/cs_qr.c diff --git a/src/vendor/cs/cs_qrsol.c b/src/vendor/cigraph/vendor/cs/cs_qrsol.c similarity index 100% rename from src/vendor/cs/cs_qrsol.c rename to src/vendor/cigraph/vendor/cs/cs_qrsol.c diff --git a/src/vendor/cs/cs_randperm.c b/src/vendor/cigraph/vendor/cs/cs_randperm.c similarity index 100% rename from src/vendor/cs/cs_randperm.c rename to src/vendor/cigraph/vendor/cs/cs_randperm.c diff --git a/src/vendor/cs/cs_reach.c b/src/vendor/cigraph/vendor/cs/cs_reach.c similarity index 100% rename from src/vendor/cs/cs_reach.c rename to src/vendor/cigraph/vendor/cs/cs_reach.c diff --git a/src/vendor/cs/cs_scatter.c b/src/vendor/cigraph/vendor/cs/cs_scatter.c similarity index 100% rename from src/vendor/cs/cs_scatter.c rename to src/vendor/cigraph/vendor/cs/cs_scatter.c diff --git a/src/vendor/cs/cs_scc.c b/src/vendor/cigraph/vendor/cs/cs_scc.c similarity index 100% rename from src/vendor/cs/cs_scc.c rename to src/vendor/cigraph/vendor/cs/cs_scc.c diff --git a/src/vendor/cs/cs_schol.c b/src/vendor/cigraph/vendor/cs/cs_schol.c similarity index 100% rename from src/vendor/cs/cs_schol.c rename to src/vendor/cigraph/vendor/cs/cs_schol.c diff --git a/src/vendor/cs/cs_spsolve.c b/src/vendor/cigraph/vendor/cs/cs_spsolve.c similarity index 100% rename from src/vendor/cs/cs_spsolve.c rename to src/vendor/cigraph/vendor/cs/cs_spsolve.c diff --git a/src/vendor/cs/cs_sqr.c b/src/vendor/cigraph/vendor/cs/cs_sqr.c similarity index 100% rename from src/vendor/cs/cs_sqr.c rename to src/vendor/cigraph/vendor/cs/cs_sqr.c diff --git a/src/vendor/cs/cs_symperm.c b/src/vendor/cigraph/vendor/cs/cs_symperm.c similarity index 100% rename from src/vendor/cs/cs_symperm.c rename to src/vendor/cigraph/vendor/cs/cs_symperm.c diff --git a/src/vendor/cs/cs_tdfs.c b/src/vendor/cigraph/vendor/cs/cs_tdfs.c similarity index 100% rename from src/vendor/cs/cs_tdfs.c rename to src/vendor/cigraph/vendor/cs/cs_tdfs.c diff --git a/src/vendor/cs/cs_transpose.c b/src/vendor/cigraph/vendor/cs/cs_transpose.c similarity index 100% rename from src/vendor/cs/cs_transpose.c rename to src/vendor/cigraph/vendor/cs/cs_transpose.c diff --git a/src/vendor/cs/cs_updown.c b/src/vendor/cigraph/vendor/cs/cs_updown.c similarity index 100% rename from src/vendor/cs/cs_updown.c rename to src/vendor/cigraph/vendor/cs/cs_updown.c diff --git a/src/vendor/cs/cs_usolve.c b/src/vendor/cigraph/vendor/cs/cs_usolve.c similarity index 100% rename from src/vendor/cs/cs_usolve.c rename to src/vendor/cigraph/vendor/cs/cs_usolve.c diff --git a/src/vendor/cs/cs_util.c b/src/vendor/cigraph/vendor/cs/cs_util.c similarity index 100% rename from src/vendor/cs/cs_util.c rename to src/vendor/cigraph/vendor/cs/cs_util.c diff --git a/src/vendor/cs/cs_utsolve.c b/src/vendor/cigraph/vendor/cs/cs_utsolve.c similarity index 100% rename from src/vendor/cs/cs_utsolve.c rename to src/vendor/cigraph/vendor/cs/cs_utsolve.c diff --git a/src/vendor/cigraph/vendor/f2c/err.c b/src/vendor/cigraph/vendor/f2c/err.c index 80a3b749839..54bdd65bc13 100644 --- a/src/vendor/cigraph/vendor/f2c/err.c +++ b/src/vendor/cigraph/vendor/f2c/err.c @@ -140,7 +140,7 @@ f__canseek(FILE *f) /*SYSDEP*/ if (S_ISBLK(x.st_mode)) return(1); #else - Help! How does fstat work on this system? +#error "Help! How does fstat work on this system?" #endif #endif return(0); /* who knows what it is? */ diff --git a/src/vendor/cigraph/vendor/plfit/CMakeLists.txt b/src/vendor/cigraph/vendor/plfit/CMakeLists.txt new file mode 100644 index 00000000000..005abd10bc5 --- /dev/null +++ b/src/vendor/cigraph/vendor/plfit/CMakeLists.txt @@ -0,0 +1,47 @@ +# Declare the files needed to compile our vendored plfit copy +add_library( + plfit_vendored + OBJECT + EXCLUDE_FROM_ALL + gss.c + hzeta.c + kolmogorov.c + lbfgs.c + mt.c + options.c + platform.c + plfit.c + plfit_error.c + rbinom.c + sampling.c +) + +target_include_directories( + plfit_vendored + PRIVATE + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +if (BUILD_SHARED_LIBS) + set_property(TARGET plfit_vendored PROPERTY POSITION_INDEPENDENT_CODE ON) +endif() + +# Since these are included as object files, they should call the +# function as is (without visibility specification) +target_compile_definitions(plfit_vendored PRIVATE IGRAPH_STATIC) + +use_all_warnings(plfit_vendored) + +if (MSVC) + target_compile_options( + plfit_vendored PRIVATE + /wd4100 + ) # disable unreferenced parameter warning +endif() + +if(IGRAPH_OPENMP_SUPPORT) + target_link_libraries(plfit_vendored PRIVATE OpenMP::OpenMP_C) +endif() diff --git a/src/vendor/plfit/arithmetic_ansi.h b/src/vendor/cigraph/vendor/plfit/arithmetic_ansi.h similarity index 99% rename from src/vendor/plfit/arithmetic_ansi.h rename to src/vendor/cigraph/vendor/plfit/arithmetic_ansi.h index c58c98a75ad..83ed11e6eb5 100644 --- a/src/vendor/plfit/arithmetic_ansi.h +++ b/src/vendor/cigraph/vendor/plfit/arithmetic_ansi.h @@ -51,7 +51,7 @@ inline static void vecfree(void *memblock) inline static void vecset(lbfgsfloatval_t *x, const lbfgsfloatval_t c, const int n) { int i; - + for (i = 0;i < n;++i) { x[i] = c; } diff --git a/src/vendor/plfit/arithmetic_sse_double.h b/src/vendor/cigraph/vendor/plfit/arithmetic_sse_double.h similarity index 100% rename from src/vendor/plfit/arithmetic_sse_double.h rename to src/vendor/cigraph/vendor/plfit/arithmetic_sse_double.h diff --git a/src/vendor/plfit/arithmetic_sse_float.h b/src/vendor/cigraph/vendor/plfit/arithmetic_sse_float.h similarity index 100% rename from src/vendor/plfit/arithmetic_sse_float.h rename to src/vendor/cigraph/vendor/plfit/arithmetic_sse_float.h diff --git a/src/vendor/plfit/gss.c b/src/vendor/cigraph/vendor/plfit/gss.c similarity index 86% rename from src/vendor/plfit/gss.c rename to src/vendor/cigraph/vendor/plfit/gss.c index 9f332c0dc8e..5c5ffbd1a50 100644 --- a/src/vendor/plfit/gss.c +++ b/src/vendor/cigraph/vendor/plfit/gss.c @@ -45,7 +45,7 @@ */ static const gss_parameter_t _defparam = { /* .epsilon = */ DBL_MIN, - /* .on_error = */ GSS_ERROR_STOP + /* .on_error = */ GSS_ERROR_STOP }; /** @@ -58,7 +58,7 @@ void gss_parameter_init(gss_parameter_t *param) { } unsigned short int gss_get_warning_flag(void) { - return gss_i_warning_flag; + return gss_i_warning_flag; } #define TERMINATE { \ @@ -80,7 +80,7 @@ unsigned short int gss_get_warning_flag(void) { retval = proc_progress(instance, x, fx, min, fmin, \ (a < b) ? a : b, (a < b) ? b : a, k); \ if (retval) { \ - TERMINATE; \ + TERMINATE; \ return PLFIT_SUCCESS; \ } \ } \ @@ -97,7 +97,7 @@ int gss(double a, double b, double *_min, double *_fmin, gss_parameter_t param = _param ? (*_param) : _defparam; - gss_i_warning_flag = 0; + gss_i_warning_flag = 0; if (a > b) { c = a; a = b; b = c; @@ -113,12 +113,12 @@ int gss(double a, double b, double *_min, double *_fmin, EVALUATE(c, fc); if (fc >= fa || fc >= fb) { - if (param.on_error == GSS_ERROR_STOP) { - return PLFIT_FAILURE; - } else { - gss_i_warning_flag = 1; - } - } + if (param.on_error == GSS_ERROR_STOP) { + return PLFIT_FAILURE; + } else { + gss_i_warning_flag = 1; + } + } while (fabs(a-b) > param.epsilon) { k++; @@ -127,12 +127,12 @@ int gss(double a, double b, double *_min, double *_fmin, EVALUATE(d, fd); if (fd >= fa || fd >= fb) { - if (param.on_error == GSS_ERROR_STOP) { - successful = 0; - break; - } else { - gss_i_warning_flag = 1; - } + if (param.on_error == GSS_ERROR_STOP) { + successful = 0; + break; + } else { + gss_i_warning_flag = 1; + } } if (fc <= fd) { @@ -146,7 +146,7 @@ int gss(double a, double b, double *_min, double *_fmin, c = (a+b) / 2.0; k++; EVALUATE(c, fc); - TERMINATE; + TERMINATE; } return successful ? PLFIT_SUCCESS : PLFIT_FAILURE; diff --git a/src/vendor/plfit/gss.h b/src/vendor/cigraph/vendor/plfit/gss.h similarity index 100% rename from src/vendor/plfit/gss.h rename to src/vendor/cigraph/vendor/plfit/gss.h diff --git a/src/vendor/plfit/hzeta.c b/src/vendor/cigraph/vendor/plfit/hzeta.c similarity index 95% rename from src/vendor/plfit/hzeta.c rename to src/vendor/cigraph/vendor/plfit/hzeta.c index eefd70c0e5c..d8f9a6d9a7b 100644 --- a/src/vendor/plfit/hzeta.c +++ b/src/vendor/cigraph/vendor/plfit/hzeta.c @@ -10,7 +10,7 @@ /* `hsl/specfunc/hzeta.c' C source file // HSL - Home Scientific Library -// Copyright (C) 2017-2018 Jerome Benoit +// Copyright (C) 2017-2022 Jerome Benoit // // HSL is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -58,10 +58,15 @@ #define GSL_LOG_DBL_MAX 7.0978271289338397e+02 #define GSL_DBL_EPSILON 2.2204460492503131e-16 -/* imported from gsl_math.h */ +/* Math constants are not part of standard C. + * The following are borrowed from igraph/src/core/math.h */ #ifndef M_LOG2E -#define M_LOG2E 1.44269504088896340735992468100 /* log_2 (e) */ +#define M_LOG2E 1.44269504088896340735992468100189214 +#endif + +#ifndef M_LN2 +#define M_LN2 0.693147180559945309417232121458176568 #endif /* imported from gsl_sf_result.h */ @@ -97,7 +102,7 @@ typedef struct gsl_sf_result_struct gsl_sf_result; // B_{2j}/(2j) static -double hsl_sf_hzeta_eulermaclaurin_series_coeffs[HSL_SF_HZETA_EULERMACLAURIN_SERIES_ORDER+1]={ +double hsl_sf_hzeta_eulermaclaurin_series_coeffs[HSL_SF_HZETA_EULERMACLAURIN_SERIES_ORDER+2]={ +1.0, +1.0/12.0, -1.0/720.0, @@ -130,12 +135,12 @@ double hsl_sf_hzeta_eulermaclaurin_series_coeffs[HSL_SF_HZETA_EULERMACLAURIN_SER +1.01530758555695563116307139454e-46, -2.57180415824187174992481940976e-48, +6.51445603523381493155843485864e-50, - -1.65013099068965245550609878048e-51 - }; // hsl_sf_hzeta_eulermaclaurin_series_coeffs + -1.65013099068965245550609878048e-51, + NAN}; // hsl_sf_hzeta_eulermaclaurin_series_coeffs // 4\zeta(2j)/(2\pi)^(2j) static -double hsl_sf_hzeta_eulermaclaurin_series_majorantratios[HSL_SF_HZETA_EULERMACLAURIN_SERIES_ORDER+1]={ +double hsl_sf_hzeta_eulermaclaurin_series_majorantratios[HSL_SF_HZETA_EULERMACLAURIN_SERIES_ORDER+2]={ -2.0, +1.0/6.0, +1.0/360.0, @@ -168,8 +173,8 @@ double hsl_sf_hzeta_eulermaclaurin_series_majorantratios[HSL_SF_HZETA_EULERMACLA +2.03061517111391126232614278906e-46, +5.14360831648374349984963881946e-48, +1.30289120704676298631168697172e-49, - +3.30026198137930491101219756091e-51 - }; // hsl_sf_hzeta_eulermaclaurin_series_majorantratios + +3.30026198137930491101219756091e-51, + NAN}; // hsl_sf_hzeta_eulermaclaurin_series_majorantratios extern @@ -234,6 +239,7 @@ int hsl_sf_hzeta_e(const double s, const double q, gsl_sf_result * result) { ratio=scp*pcp; if ((fabs(delta/ans)) < (0.5*GSL_DBL_EPSILON)) break; } + if (HSL_SF_HZETA_EULERMACLAURIN_SERIES_ORDER -#include #include #include "lbfgs.h" @@ -140,7 +139,7 @@ typedef int (*line_search_proc)( callback_data_t *cd, const lbfgs_parameter_t *param ); - + static int line_search_backtracking( int n, lbfgsfloatval_t *x, @@ -1123,7 +1122,7 @@ static int line_search_morethuente( * @param brackt The pointer to the predicate if the trial value is * bracketed. * @retval int Status value. Zero indicates a normal termination. - * + * * @see * Jorge J. More and David J. Thuente. Line search algorithm with * guaranteed sufficient decrease. ACM Transactions on Mathematical @@ -1255,7 +1254,7 @@ static int update_trial_interval( x <- x, y <- t. - Case b: if f(t) <= f(x) && f'(t)*f'(x) > 0, x <- t, y <- y. - - Case c: if f(t) <= f(x) && f'(t)*f'(x) < 0, + - Case c: if f(t) <= f(x) && f'(t)*f'(x) < 0, x <- t, y <- x. */ if (*fx < *ft) { diff --git a/src/vendor/plfit/lbfgs.h b/src/vendor/cigraph/vendor/plfit/lbfgs.h similarity index 99% rename from src/vendor/plfit/lbfgs.h rename to src/vendor/cigraph/vendor/plfit/lbfgs.h index f26ae874e49..c36a0b1f832 100644 --- a/src/vendor/plfit/lbfgs.h +++ b/src/vendor/cigraph/vendor/plfit/lbfgs.h @@ -59,7 +59,7 @@ typedef double lbfgsfloatval_t; #endif -/** +/** * \addtogroup liblbfgs_api libLBFGS API * @{ * @@ -68,7 +68,7 @@ typedef double lbfgsfloatval_t; /** * Return values of lbfgs(). - * + * * Roughly speaking, a negative value indicates an error. */ enum { @@ -365,7 +365,7 @@ typedef struct { * function and its gradients when needed. A client program must implement * this function to evaluate the values of the objective function and its * gradients, given current values of variables. - * + * * @param instance The user data sent for lbfgs() function by the client. * @param x The current values of variables. * @param g The gradient vector. The callback function must compute @@ -502,14 +502,14 @@ void lbfgs_parameter_init(lbfgs_parameter_t *param); * when libLBFGS is built with SSE/SSE2 optimization routines. A user does * not have to use this function for libLBFGS built without SSE/SSE2 * optimization. - * + * * @param n The number of variables. */ lbfgsfloatval_t* lbfgs_malloc(int n); /** * Free an array of variables. - * + * * @param x The array of variables allocated by ::lbfgs_malloc * function. */ diff --git a/src/vendor/plfit/mt.c b/src/vendor/cigraph/vendor/plfit/mt.c similarity index 94% rename from src/vendor/plfit/mt.c rename to src/vendor/cigraph/vendor/plfit/mt.c index f9c2b74609b..b99a1670bab 100644 --- a/src/vendor/plfit/mt.c +++ b/src/vendor/cigraph/vendor/plfit/mt.c @@ -11,14 +11,12 @@ * This file has been placed in the public domain. */ -#include - #include "igraph_random.h" #include "plfit_mt.h" static uint16_t get_random_uint16(void) { - return RNG_INT31() & 0xFFFF; + return RNG_INTEGER(0, 0xffff); } void plfit_mt_init(plfit_mt_rng_t* rng) { @@ -32,7 +30,7 @@ void plfit_mt_init_from_rng(plfit_mt_rng_t* rng, plfit_mt_rng_t* seeder) { for (i = 0; i < PLFIT_MT_LEN; i++) { /* RAND_MAX is guaranteed to be at least 32767, so we can use two * calls to rand() to produce a random 32-bit number */ - rng->mt_buffer[i] = (get_random_uint16() << 16) + get_random_uint16(); + rng->mt_buffer[i] = (((uint32_t) get_random_uint16()) << 16) + get_random_uint16(); } } else { for (i = 0; i < PLFIT_MT_LEN; i++) { @@ -56,7 +54,7 @@ uint32_t plfit_mt_random(plfit_mt_rng_t* rng) { int idx = rng->mt_index; uint32_t s; int i; - + if (idx == PLFIT_MT_LEN * sizeof(uint32_t)) { idx = 0; i = 0; @@ -68,7 +66,7 @@ uint32_t plfit_mt_random(plfit_mt_rng_t* rng) { s = TWIST(b, i, i+1); b[i] = b[i - MT_IB] ^ (s >> 1) ^ MAGIC(s); } - + s = TWIST(b, PLFIT_MT_LEN-1, 0); b[PLFIT_MT_LEN-1] = b[MT_IA-1] ^ (s >> 1) ^ MAGIC(s); } @@ -79,7 +77,7 @@ uint32_t plfit_mt_random(plfit_mt_rng_t* rng) { Matsumoto and Nishimura additionally confound the bits returned to the caller but this doesn't increase the randomness, and slows down the generator by as much as 25%. So I omit these operations here. - + r ^= (r >> 11); r ^= (r << 7) & 0x9D2C5680; r ^= (r << 15) & 0xEFC60000; diff --git a/src/vendor/plfit/options.c b/src/vendor/cigraph/vendor/plfit/options.c similarity index 100% rename from src/vendor/plfit/options.c rename to src/vendor/cigraph/vendor/plfit/options.c diff --git a/src/vendor/plfit/platform.c b/src/vendor/cigraph/vendor/plfit/platform.c similarity index 100% rename from src/vendor/plfit/platform.c rename to src/vendor/cigraph/vendor/plfit/platform.c diff --git a/src/vendor/plfit/platform.h b/src/vendor/cigraph/vendor/plfit/platform.h similarity index 100% rename from src/vendor/plfit/platform.h rename to src/vendor/cigraph/vendor/plfit/platform.h diff --git a/src/vendor/plfit/plfit.c b/src/vendor/cigraph/vendor/plfit/plfit.c similarity index 88% rename from src/vendor/plfit/plfit.c rename to src/vendor/cigraph/vendor/plfit/plfit.c index 266a9b02add..6eae747e8d3 100644 --- a/src/vendor/plfit/plfit.c +++ b/src/vendor/cigraph/vendor/plfit/plfit.c @@ -49,10 +49,10 @@ PLFIT_ERROR("xmin must be at least 1", PLFIT_EINVAL); \ } -static int plfit_i_resample_continuous(double* xs_head, size_t num_smaller, +static int plfit_i_resample_continuous(const double* xs_head, size_t num_smaller, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result); -static int plfit_i_resample_discrete(double* xs_head, size_t num_smaller, +static int plfit_i_resample_discrete(const double* xs_head, size_t num_smaller, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result); @@ -62,9 +62,9 @@ static int double_comparator(const void *a, const void *b) { return (*da > *db) - (*da < *db); } -static int plfit_i_copy_and_sort(double* xs, size_t n, double** result) { +static int plfit_i_copy_and_sort(const double* xs, size_t n, double** result) { *result = (double*)malloc(sizeof(double) * n); - if (*result == 0) { + if (*result == NULL) { PLFIT_ERROR("cannot create sorted copy of input data", PLFIT_ENOMEM); } @@ -85,8 +85,8 @@ static int plfit_i_copy_and_sort(double* xs, size_t n, double** result) { * \return the nubmer of elements in the array that are smaller than the given * value. */ -static size_t count_smaller(double* begin, double* end, double xmin) { - double* p; +static size_t count_smaller(const double* begin, const double* end, double xmin) { + const double* p; size_t counter = 0; for (p = begin; p < end; p++) { @@ -111,14 +111,14 @@ static size_t count_smaller(double* begin, double* end, double xmin) { * \return pointer to the head of the new array or 0 if there is not enough * memory */ -static double* extract_smaller(double* begin, double* end, double xmin, +static double* extract_smaller(const double* begin, const double* end, double xmin, size_t* result_length) { size_t counter = count_smaller(begin, end, xmin); double *p, *result; - result = calloc(counter, sizeof(double)); - if (result == 0) - return 0; + result = calloc(counter > 0 ? counter : 1, sizeof(double)); + if (result == NULL) + return NULL; for (p = result; begin < end; begin++) { if (*begin < xmin) { @@ -144,7 +144,7 @@ static double* extract_smaller(double* begin, double* end, double xmin, * given array is returned here. It is left unchanged if * the function returns with an error. * - * \return pointer to the head of the new array or 0 if there is not enough + * \return pointer to the head of the new array or NULL if there is not enough * memory */ static double** unique_element_pointers(double* begin, double* end, size_t* result_length) { @@ -157,7 +157,7 @@ static double** unique_element_pointers(double* begin, double* end, size_t* resu /* Special case: empty array */ if (begin == end) { result = calloc(1, sizeof(double*)); - if (result != 0) { + if (result != NULL) { result[0] = 0; if (result_length != 0) { *result_length = 0; @@ -168,8 +168,8 @@ static double** unique_element_pointers(double* begin, double* end, size_t* resu /* Allocate initial result array, including the guard element */ result = calloc(num_elts+1, sizeof(double*)); - if (result == 0) - return 0; + if (result == NULL) + return NULL; prev_x = *begin; result[used_elts++] = begin; @@ -182,10 +182,14 @@ static double** unique_element_pointers(double* begin, double* end, size_t* resu /* New block found */ if (used_elts >= num_elts) { /* Array full; allocate a new chunk */ + double** tmp; num_elts = num_elts*2 + 1; - result = realloc(result, sizeof(double*) * (num_elts+1)); - if (result == 0) - return 0; + tmp = realloc(result, sizeof(double*) * (num_elts+1)); + if (tmp == NULL) { + free(result); + return NULL; + } + result = tmp; } /* Store the new element */ @@ -210,7 +214,7 @@ static void plfit_i_perform_finite_size_correction(plfit_result_t* result, size_ /********** Continuous power law distribution fitting **********/ -static void plfit_i_logsum_less_than_continuous(double* begin, double* end, +static void plfit_i_logsum_less_than_continuous(const double* begin, const double* end, double xmin, double* result, size_t* m) { double logsum = 0.0; size_t count = 0; @@ -226,14 +230,14 @@ static void plfit_i_logsum_less_than_continuous(double* begin, double* end, *result = logsum; } -static double plfit_i_logsum_continuous(double* begin, double* end, double xmin) { +static double plfit_i_logsum_continuous(const double* begin, const double* end, double xmin) { double logsum = 0.0; for (; begin != end; begin++) logsum += log(*begin / xmin); return logsum; } -static int plfit_i_estimate_alpha_continuous(double* xs, size_t n, +static int plfit_i_estimate_alpha_continuous(const double* xs, size_t n, double xmin, double* alpha) { double result; size_t m; @@ -251,9 +255,9 @@ static int plfit_i_estimate_alpha_continuous(double* xs, size_t n, return PLFIT_SUCCESS; } -static int plfit_i_estimate_alpha_continuous_sorted(double* xs, size_t n, +static int plfit_i_estimate_alpha_continuous_sorted(const double* xs, size_t n, double xmin, double* alpha) { - double* end = xs+n; + const double* end = xs+n; XMIN_CHECK_ZERO; @@ -267,7 +271,7 @@ static int plfit_i_estimate_alpha_continuous_sorted(double* xs, size_t n, return PLFIT_SUCCESS; } -static int plfit_i_ks_test_continuous(double* xs, double* xs_end, +static int plfit_i_ks_test_continuous(const double* xs, const double* xs_end, const double alpha, const double xmin, double* D) { /* Assumption: xs is sorted and cut off at xmin so the first element is * always larger than or equal to xmin. */ @@ -290,7 +294,7 @@ static int plfit_i_ks_test_continuous(double* xs, double* xs_end, return PLFIT_SUCCESS; } -static int plfit_i_calculate_p_value_continuous(double* xs, size_t n, +static int plfit_i_calculate_p_value_continuous(const double* xs, size_t n, const plfit_continuous_options_t *options, plfit_bool_t xmin_fixed, plfit_result_t *result) { long int num_trials; @@ -350,7 +354,7 @@ static int plfit_i_calculate_p_value_continuous(double* xs, size_t n, #endif /* Allocate memory to sample into */ - ys = calloc(n, sizeof(double)); + ys = calloc(n > 0 ? n : 1, sizeof(double)); if (ys == 0) { retval = PLFIT_ENOMEM; } else { @@ -387,7 +391,7 @@ static int plfit_i_calculate_p_value_continuous(double* xs, size_t n, return retval; } -int plfit_log_likelihood_continuous(double* xs, size_t n, double alpha, +int plfit_log_likelihood_continuous(const double* xs, size_t n, double alpha, double xmin, double* L) { double logsum, c; size_t m; @@ -404,9 +408,9 @@ int plfit_log_likelihood_continuous(double* xs, size_t n, double alpha, return PLFIT_SUCCESS; } -int plfit_estimate_alpha_continuous_sorted(double* xs, size_t n, double xmin, +int plfit_estimate_alpha_continuous_sorted(const double* xs, size_t n, double xmin, const plfit_continuous_options_t* options, plfit_result_t *result) { - double *begin, *end; + const double *begin, *end; if (!options) options = &plfit_continuous_default_options; @@ -432,7 +436,7 @@ int plfit_estimate_alpha_continuous_sorted(double* xs, size_t n, double xmin, return PLFIT_SUCCESS; } -int plfit_estimate_alpha_continuous(double* xs, size_t n, double xmin, +int plfit_estimate_alpha_continuous(const double* xs, size_t n, double xmin, const plfit_continuous_options_t* options, plfit_result_t *result) { double *xs_copy; @@ -540,7 +544,7 @@ static int plfit_i_continuous_xmin_opt_linear_scan( local_opt_data.last.xmin, local_opt_data.last.D); #endif local_best_result = local_opt_data.last; - local_best_n = local_opt_data.end - local_opt_data.probes[i] + 1; + local_best_n = local_opt_data.end - local_opt_data.probes[i]; } } @@ -569,7 +573,7 @@ static int plfit_i_continuous_xmin_opt_linear_scan( return PLFIT_SUCCESS; } -int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* options, +int plfit_continuous(const double* xs, size_t n, const plfit_continuous_options_t* options, plfit_result_t* result) { gss_parameter_t gss_param; plfit_continuous_xmin_opt_data_t opt_data; @@ -583,10 +587,16 @@ int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* opt int success; size_t i, best_n, num_uniques = 0; - double x, *px, **uniques; + double x, *px, **uniques, **strata; + int error_code, retval = PLFIT_SUCCESS; DATA_POINTS_CHECK; + /* Set up pointers that we will allocate */ + opt_data.begin = NULL; + uniques = NULL; + strata = NULL; + /* Sane defaults */ best_n = n; if (!options) @@ -599,8 +609,10 @@ int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* opt /* Create an array containing pointers to the unique elements of the input. From * each block of unique elements, we add the pointer to the first one. */ uniques = unique_element_pointers(opt_data.begin, opt_data.end, &num_uniques); - if (uniques == 0) + if (uniques == NULL) { + free(opt_data.begin); PLFIT_ERROR("cannot fit continuous power-law", PLFIT_ENOMEM); + } /* We will now determine the best xmin that yields the lowest D-score. The * 'success' variable will denote whether the search procedure we tried was @@ -633,8 +645,13 @@ int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* opt * area around it more thoroughly. */ const size_t subdivision_length = 10; size_t num_strata = num_uniques / subdivision_length; - double **strata = calloc(num_strata, sizeof(double*)); - int error_code; + + strata = calloc(num_strata, sizeof(double*)); + if (strata == NULL) { + free(uniques); + free(opt_data.begin); + PLFIT_ERROR("cannot fit continuous power-law", PLFIT_ENOMEM); + } for (i = 0; i < num_strata; i++) { strata[i] = uniques[i * subdivision_length]; @@ -644,8 +661,8 @@ int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* opt opt_data.num_probes = num_strata; error_code = plfit_i_continuous_xmin_opt_linear_scan(&opt_data, &best_result, &best_n); if (error_code != PLFIT_SUCCESS) { - free(strata); - return error_code; + retval = error_code; + goto cleanup; } opt_data.num_probes = 0; @@ -664,14 +681,17 @@ int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* opt } } - free(strata); + free(strata); strata = NULL; + if (opt_data.num_probes > 0) { /* Do a strict linear scan in the subrange determined above */ - PLFIT_CHECK( - plfit_i_continuous_xmin_opt_linear_scan( - &opt_data, &best_result, &best_n - ) - ); + error_code = plfit_i_continuous_xmin_opt_linear_scan( + &opt_data, &best_result, &best_n + ); + if (error_code) { + retval = error_code; + goto cleanup; + } success = 1; } else { /* This should not happen, but we handle it anyway */ @@ -689,26 +709,44 @@ int plfit_continuous(double* xs, size_t n, const plfit_continuous_options_t* opt /* More advanced search methods failed or were skipped; try linear search */ opt_data.probes = uniques; opt_data.num_probes = num_uniques; - PLFIT_CHECK(plfit_i_continuous_xmin_opt_linear_scan(&opt_data, &best_result, &best_n)); + error_code = plfit_i_continuous_xmin_opt_linear_scan(&opt_data, &best_result, &best_n); + if (error_code) { + retval = error_code; + goto cleanup; + } success = 1; } /* Get rid of the uniques array, we don't need it any more */ - free(uniques); + free(uniques); uniques = NULL; /* Sort out the result */ *result = best_result; if (options->finite_size_correction) plfit_i_perform_finite_size_correction(result, best_n); - PLFIT_CHECK(plfit_log_likelihood_continuous(opt_data.begin + n - best_n, best_n, - result->alpha, result->xmin, &result->L)); - PLFIT_CHECK(plfit_i_calculate_p_value_continuous(opt_data.begin, n, options, 0, result)); + error_code = plfit_log_likelihood_continuous( + opt_data.begin + n - best_n, best_n, result->alpha, result->xmin, + &result->L + ); + if (error_code) { + retval = error_code; + goto cleanup; + } - /* Get rid of the copied data as well */ + error_code = plfit_i_calculate_p_value_continuous(opt_data.begin, n, options, 0, result); + if (error_code) { + retval = error_code; + goto cleanup; + } + +cleanup: + /* It is safe to call free() on NULL */ + free(strata); + free(uniques); free(opt_data.begin); - return PLFIT_SUCCESS; + return retval; } /********** Discrete power law distribution fitting **********/ @@ -719,14 +757,14 @@ typedef struct { double xmin; } plfit_i_estimate_alpha_discrete_data_t; -static double plfit_i_logsum_discrete(double* begin, double* end, double xmin) { +static double plfit_i_logsum_discrete(const double* begin, const double* end, double xmin) { double logsum = 0.0; for (; begin != end; begin++) logsum += log(*begin); return logsum; } -static void plfit_i_logsum_less_than_discrete(double* begin, double* end, double xmin, +static void plfit_i_logsum_less_than_discrete(const double* begin, const double* end, double xmin, double* logsum, size_t* m) { double result = 0.0; size_t count = 0; @@ -747,7 +785,7 @@ static lbfgsfloatval_t plfit_i_estimate_alpha_discrete_lbfgs_evaluate( void* instance, const lbfgsfloatval_t* x, lbfgsfloatval_t* g, const int n, const lbfgsfloatval_t step) { - plfit_i_estimate_alpha_discrete_data_t* data; + const plfit_i_estimate_alpha_discrete_data_t* data; lbfgsfloatval_t result; double dx = step; double huge = 1e10; /* pseudo-infinity; apparently DBL_MAX does not work */ @@ -802,7 +840,7 @@ static int plfit_i_estimate_alpha_discrete_lbfgs_progress(void* instance, return 0; } -static int plfit_i_estimate_alpha_discrete_linear_scan(double* xs, size_t n, +static int plfit_i_estimate_alpha_discrete_linear_scan(const double* xs, size_t n, double xmin, double* alpha, const plfit_discrete_options_t* options, plfit_bool_t sorted) { double curr_alpha, best_alpha, L, L_max; @@ -842,7 +880,7 @@ static int plfit_i_estimate_alpha_discrete_linear_scan(double* xs, size_t n, return PLFIT_SUCCESS; } -static int plfit_i_estimate_alpha_discrete_lbfgs(double* xs, size_t n, double xmin, +static int plfit_i_estimate_alpha_discrete_lbfgs(const double* xs, size_t n, double xmin, double* alpha, const plfit_discrete_options_t* options, plfit_bool_t sorted) { lbfgs_parameter_t param; lbfgsfloatval_t* variables; @@ -892,7 +930,7 @@ static int plfit_i_estimate_alpha_discrete_lbfgs(double* xs, size_t n, double xm return PLFIT_SUCCESS; } -static int plfit_i_estimate_alpha_discrete_fast(double* xs, size_t n, double xmin, +static int plfit_i_estimate_alpha_discrete_fast(const double* xs, size_t n, double xmin, double* alpha, const plfit_discrete_options_t* options, plfit_bool_t sorted) { plfit_continuous_options_t cont_options; @@ -911,7 +949,7 @@ static int plfit_i_estimate_alpha_discrete_fast(double* xs, size_t n, double xmi } } -static int plfit_i_estimate_alpha_discrete(double* xs, size_t n, double xmin, +static int plfit_i_estimate_alpha_discrete(const double* xs, size_t n, double xmin, double* alpha, const plfit_discrete_options_t* options, plfit_bool_t sorted) { switch (options->alpha_method) { @@ -937,7 +975,7 @@ static int plfit_i_estimate_alpha_discrete(double* xs, size_t n, double xmin, return PLFIT_SUCCESS; } -static int plfit_i_ks_test_discrete(double* xs, double* xs_end, const double alpha, +static int plfit_i_ks_test_discrete(const double* xs, const double* xs_end, const double alpha, const double xmin, double* D) { /* Assumption: xs is sorted and cut off at xmin so the first element is * always larger than or equal to xmin. */ @@ -978,7 +1016,7 @@ static int plfit_i_ks_test_discrete(double* xs, double* xs_end, const double alp return PLFIT_SUCCESS; } -static int plfit_i_calculate_p_value_discrete(double* xs, size_t n, +static int plfit_i_calculate_p_value_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options, plfit_bool_t xmin_fixed, plfit_result_t *result) { long int num_trials; @@ -1040,8 +1078,8 @@ static int plfit_i_calculate_p_value_discrete(double* xs, size_t n, #endif /* Allocate memory to sample into */ - ys = calloc(n, sizeof(double)); - if (ys == 0) { + ys = calloc(n > 0 ? n : 1, sizeof(double)); + if (ys == NULL) { retval = PLFIT_ENOMEM; } else { /* The main for loop starts here. */ @@ -1078,7 +1116,7 @@ static int plfit_i_calculate_p_value_discrete(double* xs, size_t n, return retval; } -int plfit_log_likelihood_discrete(double* xs, size_t n, double alpha, double xmin, double* L) { +int plfit_log_likelihood_discrete(const double* xs, size_t n, double alpha, double xmin, double* L) { double result; size_t m; @@ -1095,7 +1133,7 @@ int plfit_log_likelihood_discrete(double* xs, size_t n, double alpha, double xmi return PLFIT_SUCCESS; } -int plfit_estimate_alpha_discrete(double* xs, size_t n, double xmin, +int plfit_estimate_alpha_discrete(const double* xs, size_t n, double xmin, const plfit_discrete_options_t* options, plfit_result_t *result) { double *xs_copy, *begin, *end; @@ -1139,13 +1177,13 @@ int plfit_estimate_alpha_discrete(double* xs, size_t n, double xmin, return PLFIT_SUCCESS; } -int plfit_discrete(double* xs, size_t n, const plfit_discrete_options_t* options, +int plfit_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options, plfit_result_t* result) { double curr_D, curr_alpha; plfit_result_t best_result; double *xs_copy, *px, *end, *end_xmin, prev_x; size_t best_n; - int m; + size_t m; if (!options) options = &plfit_discrete_default_options; @@ -1220,7 +1258,7 @@ int plfit_discrete(double* xs, size_t n, const plfit_discrete_options_t* options if (options->finite_size_correction) plfit_i_perform_finite_size_correction(result, best_n); - PLFIT_CHECK(plfit_log_likelihood_discrete(xs_copy+(n-best_n), best_n, + PLFIT_CHECK(plfit_log_likelihood_discrete(xs_copy + n - best_n, best_n, result->alpha, result->xmin, &result->L)); PLFIT_CHECK(plfit_i_calculate_p_value_discrete(xs_copy, n, options, 0, result)); @@ -1231,7 +1269,7 @@ int plfit_discrete(double* xs, size_t n, const plfit_discrete_options_t* options /***** resampling routines to generate synthetic replicates ****/ -static int plfit_i_resample_continuous(double* xs_head, size_t num_smaller, +static int plfit_i_resample_continuous(const double* xs_head, size_t num_smaller, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result) { @@ -1252,7 +1290,7 @@ static int plfit_i_resample_continuous(double* xs_head, size_t num_smaller, return PLFIT_SUCCESS; } -int plfit_resample_continuous(double* xs, size_t n, double alpha, double xmin, +int plfit_resample_continuous(const double* xs, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result) { double *xs_head; size_t num_smaller = 0; @@ -1272,7 +1310,7 @@ int plfit_resample_continuous(double* xs, size_t n, double alpha, double xmin, return retval; } -static int plfit_i_resample_discrete(double* xs_head, size_t num_smaller, size_t n, +static int plfit_i_resample_discrete(const double* xs_head, size_t num_smaller, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result) { @@ -1293,7 +1331,7 @@ static int plfit_i_resample_discrete(double* xs_head, size_t num_smaller, size_t return PLFIT_SUCCESS; } -int plfit_resample_discrete(double* xs, size_t n, double alpha, double xmin, +int plfit_resample_discrete(const double* xs, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result) { double *xs_head; size_t num_smaller = 0; @@ -1315,7 +1353,7 @@ int plfit_resample_discrete(double* xs, size_t n, double alpha, double xmin, /******** calculating the p-value of a fitted model only *******/ -int plfit_calculate_p_value_continuous(double* xs, size_t n, +int plfit_calculate_p_value_continuous(const double* xs, size_t n, const plfit_continuous_options_t* options, plfit_bool_t xmin_fixed, plfit_result_t *result) { double* xs_copy; @@ -1328,7 +1366,7 @@ int plfit_calculate_p_value_continuous(double* xs, size_t n, return PLFIT_SUCCESS; } -int plfit_calculate_p_value_discrete(double* xs, size_t n, +int plfit_calculate_p_value_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options, plfit_bool_t xmin_fixed, plfit_result_t *result) { double* xs_copy; diff --git a/src/vendor/plfit/plfit.h b/src/vendor/cigraph/vendor/plfit/plfit.h similarity index 83% rename from src/vendor/plfit/plfit.h rename to src/vendor/cigraph/vendor/plfit/plfit.h index afc0348945d..52b55454421 100644 --- a/src/vendor/plfit/plfit.h +++ b/src/vendor/cigraph/vendor/plfit/plfit.h @@ -99,40 +99,40 @@ extern const plfit_discrete_options_t plfit_discrete_default_options; /********** continuous power law distribution fitting **********/ -int plfit_log_likelihood_continuous(double* xs, size_t n, double alpha, +int plfit_log_likelihood_continuous(const double* xs, size_t n, double alpha, double xmin, double* l); -int plfit_estimate_alpha_continuous(double* xs, size_t n, double xmin, +int plfit_estimate_alpha_continuous(const double* xs, size_t n, double xmin, const plfit_continuous_options_t* options, plfit_result_t* result); -int plfit_continuous(double* xs, size_t n, +int plfit_continuous(const double* xs, size_t n, const plfit_continuous_options_t* options, plfit_result_t* result); /*********** discrete power law distribution fitting ***********/ -int plfit_estimate_alpha_discrete(double* xs, size_t n, double xmin, +int plfit_estimate_alpha_discrete(const double* xs, size_t n, double xmin, const plfit_discrete_options_t* options, plfit_result_t *result); -int plfit_log_likelihood_discrete(double* xs, size_t n, double alpha, double xmin, double* l); -int plfit_discrete(double* xs, size_t n, const plfit_discrete_options_t* options, +int plfit_log_likelihood_discrete(const double* xs, size_t n, double alpha, double xmin, double* l); +int plfit_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options, plfit_result_t* result); /***** resampling routines to generate synthetic replicates ****/ -int plfit_resample_continuous(double* xs, size_t n, double alpha, double xmin, +int plfit_resample_continuous(const double* xs, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result); -int plfit_resample_discrete(double* xs, size_t n, double alpha, double xmin, +int plfit_resample_discrete(const double* xs, size_t n, double alpha, double xmin, size_t num_samples, plfit_mt_rng_t* rng, double* result); /******** calculating the p-value of a fitted model only *******/ -int plfit_calculate_p_value_continuous(double* xs, size_t n, +int plfit_calculate_p_value_continuous(const double* xs, size_t n, const plfit_continuous_options_t* options, plfit_bool_t xmin_fixed, plfit_result_t *result); -int plfit_calculate_p_value_discrete(double* xs, size_t n, +int plfit_calculate_p_value_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options, plfit_bool_t xmin_fixed, plfit_result_t *result); /************* calculating descriptive statistics **************/ -int plfit_moments(double* data, size_t n, double* mean, double* variance, +int plfit_moments(const double* data, size_t n, double* mean, double* variance, double* skewness, double* kurtosis); __END_DECLS diff --git a/src/vendor/plfit/plfit_error.c b/src/vendor/cigraph/vendor/plfit/plfit_error.c similarity index 94% rename from src/vendor/plfit/plfit_error.c rename to src/vendor/cigraph/vendor/plfit/plfit_error.c index d93d1c0db32..81bb31b5ba1 100644 --- a/src/vendor/plfit/plfit_error.c +++ b/src/vendor/cigraph/vendor/plfit/plfit_error.c @@ -22,13 +22,14 @@ #include "plfit_error.h" #include "platform.h" -static char *plfit_i_error_strings[] = { +static const char *plfit_i_error_strings[] = { "No error", "Failed", "Invalid value", "Underflow", "Overflow", - "Not enough memory" + "Not enough memory", + "Maximum number of iterations exceeded" }; #ifndef USING_R diff --git a/src/vendor/plfit/plfit_error.h b/src/vendor/cigraph/vendor/plfit/plfit_error.h similarity index 97% rename from src/vendor/plfit/plfit_error.h rename to src/vendor/cigraph/vendor/plfit/plfit_error.h index e5429975a07..b9170b380a8 100644 --- a/src/vendor/plfit/plfit_error.h +++ b/src/vendor/cigraph/vendor/plfit/plfit_error.h @@ -38,7 +38,8 @@ enum { PLFIT_EINVAL = 2, PLFIT_UNDRFLOW = 3, PLFIT_OVERFLOW = 4, - PLFIT_ENOMEM = 5 + PLFIT_ENOMEM = 5, + PLFIT_EMAXITER = 6 }; #if (defined(__GNUC__) && GCC_VERSION_MAJOR >= 3) @@ -55,7 +56,7 @@ enum { if (PLFIT_UNLIKELY(plfit_i_ret != PLFIT_SUCCESS)) {\ return plfit_i_ret; \ } \ - } while(0) + } while (0) #define PLFIT_ERROR(reason,plfit_errno) \ do {\ diff --git a/src/vendor/plfit/plfit_mt.h b/src/vendor/cigraph/vendor/plfit/plfit_mt.h similarity index 100% rename from src/vendor/plfit/plfit_mt.h rename to src/vendor/cigraph/vendor/plfit/plfit_mt.h diff --git a/src/vendor/plfit/plfit_sampling.h b/src/vendor/cigraph/vendor/plfit/plfit_sampling.h similarity index 100% rename from src/vendor/plfit/plfit_sampling.h rename to src/vendor/cigraph/vendor/plfit/plfit_sampling.h diff --git a/src/vendor/plfit/plfit_version.h b/src/vendor/cigraph/vendor/plfit/plfit_version.h similarity index 93% rename from src/vendor/plfit/plfit_version.h rename to src/vendor/cigraph/vendor/plfit/plfit_version.h index 1212dd1cd1f..37da90abc28 100644 --- a/src/vendor/plfit/plfit_version.h +++ b/src/vendor/cigraph/vendor/plfit/plfit_version.h @@ -22,7 +22,7 @@ #define PLFIT_VERSION_MAJOR 0 #define PLFIT_VERSION_MINOR 9 -#define PLFIT_VERSION_PATCH 3 -#define PLFIT_VERSION_STRING "0.9.3" +#define PLFIT_VERSION_PATCH 4 +#define PLFIT_VERSION_STRING "0.9.4" #endif diff --git a/src/vendor/plfit/rbinom.c b/src/vendor/cigraph/vendor/plfit/rbinom.c similarity index 98% rename from src/vendor/plfit/rbinom.c rename to src/vendor/cigraph/vendor/plfit/rbinom.c index 771f972950a..354398d4a10 100644 --- a/src/vendor/plfit/rbinom.c +++ b/src/vendor/cigraph/vendor/plfit/rbinom.c @@ -41,7 +41,6 @@ * modifications as well. */ -#include #include #include #include "plfit_sampling.h" @@ -162,7 +161,7 @@ double plfit_rbinom(double nin, double pp, plfit_mt_rng_t* rng) goto finis; } else { /* squeezing using upper and lower bounds on log(f(x)) */ - amaxp = (k / npq) * ((k * (k / 3. + 0.625) + 0.1666666666666) / npq + 0.5); + amaxp = (k / npq) * ((k * (k / 3. + 0.625) + (1.0 / 6.0)) / npq + 0.5); ynorm = -k * k / (2.0 * npq); alv = log(v); if (alv < ynorm - amaxp) diff --git a/src/vendor/plfit/sampling.c b/src/vendor/cigraph/vendor/plfit/sampling.c similarity index 95% rename from src/vendor/plfit/sampling.c rename to src/vendor/cigraph/vendor/plfit/sampling.c index 4becf134c20..8fb26ead821 100644 --- a/src/vendor/plfit/sampling.c +++ b/src/vendor/cigraph/vendor/plfit/sampling.c @@ -187,12 +187,12 @@ int plfit_walker_alias_sampler_init(plfit_walker_alias_sampler_t* sampler, ps_end = ps + n; /* Initialize indexes and probs */ - sampler->indexes = (long int*)calloc(n, sizeof(long int)); - if (sampler->indexes == 0) { + sampler->indexes = (long int*)calloc(n > 0 ? n : 1, sizeof(long int)); + if (sampler->indexes == NULL) { return PLFIT_ENOMEM; } - sampler->probs = (double*)calloc(n, sizeof(double)); - if (sampler->probs == 0) { + sampler->probs = (double*)calloc(n > 0 ? n : 1, sizeof(double)); + if (sampler->probs == NULL) { free(sampler->indexes); return PLFIT_ENOMEM; } @@ -215,14 +215,14 @@ int plfit_walker_alias_sampler_init(plfit_walker_alias_sampler_t* sampler, } /* Allocate space for short & long stick indexes */ - long_sticks = (long int*)calloc(num_long_sticks, sizeof(long int)); - if (long_sticks == 0) { + long_sticks = (long int*)calloc(num_long_sticks > 0 ? num_long_sticks : 1, sizeof(long int)); + if (long_sticks == NULL) { free(sampler->probs); free(sampler->indexes); return PLFIT_ENOMEM; } - short_sticks = (long int*)calloc(num_long_sticks, sizeof(long int)); - if (short_sticks == 0) { + short_sticks = (long int*)calloc(num_short_sticks > 0 ? num_short_sticks : 1, sizeof(long int)); + if (short_sticks == NULL) { free(sampler->probs); free(sampler->indexes); free(long_sticks); diff --git a/src/vendor/config.h b/src/vendor/config.h new file mode 100644 index 00000000000..f34c3b5a754 --- /dev/null +++ b/src/vendor/config.h @@ -0,0 +1,33 @@ +#ifndef IGRAPH_PRIVATE_CONFIG_H +#define IGRAPH_PRIVATE_CONFIG_H + +#include "igraph_config.h" + +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +/* #undef HAVE__STRICMP */ +/* #undef HAVE__STRNICMP */ +/* #undef HAVE_STRDUP */ +/* #undef HAVE_STRNDUP */ +// #define HAVE_USELOCALE 1 +/* #undef HAVE_XLOCALE */ +/* #undef HAVE__CONFIGTHREADLOCALE */ + +#define HAVE_BUILTIN_OVERFLOW 1 + +/* #undef HAVE__UMUL128 */ +/* #undef HAVE___UMULH */ +#define HAVE___UINT128_T 1 + +#define HAVE_GLPK 1 +#define HAVE_LIBXML 1 + +/* #undef INTERNAL_BLAS */ +/* #undef INTERNAL_LAPACK */ +/* #undef INTERNAL_ARPACK */ +/* #undef INTERNAL_GMP */ + +#define IGRAPH_F77_SAVE +#define IGRAPH_THREAD_LOCAL + +#endif diff --git a/src/vendor/cs/SuiteSparse_config.h b/src/vendor/cs/SuiteSparse_config.h deleted file mode 100644 index bd0ccedbe8b..00000000000 --- a/src/vendor/cs/SuiteSparse_config.h +++ /dev/null @@ -1,221 +0,0 @@ -/* ========================================================================== */ -/* === SuiteSparse_config =================================================== */ -/* ========================================================================== */ - -/* Configuration file for SuiteSparse: a Suite of Sparse matrix packages - * (AMD, COLAMD, CCOLAMD, CAMD, CHOLMOD, UMFPACK, CXSparse, and others). - * - * SuiteSparse_config.h provides the definition of the long integer. On most - * systems, a C program can be compiled in LP64 mode, in which long's and - * pointers are both 64-bits, and int's are 32-bits. Windows 64, however, uses - * the LLP64 model, in which int's and long's are 32-bits, and long long's and - * pointers are 64-bits. - * - * SuiteSparse packages that include long integer versions are - * intended for the LP64 mode. However, as a workaround for Windows 64 - * (and perhaps other systems), the long integer can be redefined. - * - * If _WIN64 is defined, then the __int64 type is used instead of long. - * - * The long integer can also be defined at compile time. For example, this - * could be added to SuiteSparse_config.mk: - * - * CFLAGS = -O -D'SuiteSparse_long=long long' \ - * -D'SuiteSparse_long_max=9223372036854775801' -D'SuiteSparse_long_idd="lld"' - * - * This file defines SuiteSparse_long as either long (on all but _WIN64) or - * __int64 on Windows 64. The intent is that a SuiteSparse_long is always a - * 64-bit integer in a 64-bit code. ptrdiff_t might be a better choice than - * long; it is always the same size as a pointer. - * - * This file also defines the SUITESPARSE_VERSION and related definitions. - * - * Copyright (c) 2012, Timothy A. Davis. No licensing restrictions apply - * to this file or to the SuiteSparse_config directory. - * Author: Timothy A. Davis. - */ - -#ifndef SUITESPARSE_CONFIG_H -#define SUITESPARSE_CONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* ========================================================================== */ -/* === SuiteSparse_long ===================================================== */ -/* ========================================================================== */ - -#ifndef SuiteSparse_long - -#ifdef _WIN64 - -#define SuiteSparse_long __int64 -#define SuiteSparse_long_max _I64_MAX -#define SuiteSparse_long_idd "I64d" - -#else - -#define SuiteSparse_long long -#define SuiteSparse_long_max LONG_MAX -#define SuiteSparse_long_idd "ld" - -#endif -#define SuiteSparse_long_id "%" SuiteSparse_long_idd -#endif - -/* Disable unneeded parts for igraph */ -#if 0 /* start comment */ - -/* ========================================================================== */ -/* === SuiteSparse_config parameters and functions ========================== */ -/* ========================================================================== */ - -/* SuiteSparse-wide parameters are placed in this struct. It is meant to be - an extern, globally-accessible struct. It is not meant to be updated - frequently by multiple threads. Rather, if an application needs to modify - SuiteSparse_config, it should do it once at the beginning of the application, - before multiple threads are launched. - - The intent of these function pointers is that they not be used in your - application directly, except to assign them to the desired user-provided - functions. Rather, you should use the - */ - -struct SuiteSparse_config_struct -{ - void *(*malloc_func) (size_t) ; /* pointer to malloc */ - void *(*calloc_func) (size_t, size_t) ; /* pointer to calloc */ - void *(*realloc_func) (void *, size_t) ; /* pointer to realloc */ - void (*free_func) (void *) ; /* pointer to free */ - int (*printf_func) (const char *, ...) ; /* pointer to printf */ - double (*hypot_func) (double, double) ; /* pointer to hypot */ - int (*divcomplex_func) (double, double, double, double, double *, double *); -} ; - -extern struct SuiteSparse_config_struct SuiteSparse_config ; - -void SuiteSparse_start ( void ) ; /* called to start SuiteSparse */ - -void SuiteSparse_finish ( void ) ; /* called to finish SuiteSparse */ - -void *SuiteSparse_malloc /* pointer to allocated block of memory */ -( - size_t nitems, /* number of items to malloc (>=1 is enforced) */ - size_t size_of_item /* sizeof each item */ -) ; - -void *SuiteSparse_calloc /* pointer to allocated block of memory */ -( - size_t nitems, /* number of items to calloc (>=1 is enforced) */ - size_t size_of_item /* sizeof each item */ -) ; - -void *SuiteSparse_realloc /* pointer to reallocated block of memory, or - to original block if the realloc failed. */ -( - size_t nitems_new, /* new number of items in the object */ - size_t nitems_old, /* old number of items in the object */ - size_t size_of_item, /* sizeof each item */ - void *p, /* old object to reallocate */ - int *ok /* 1 if successful, 0 otherwise */ -) ; - -void *SuiteSparse_free /* always returns NULL */ -( - void *p /* block to free */ -) ; - -void SuiteSparse_tic /* start the timer */ -( - double tic [2] /* output, contents undefined on input */ -) ; - -double SuiteSparse_toc /* return time in seconds since last tic */ -( - double tic [2] /* input: from last call to SuiteSparse_tic */ -) ; - -double SuiteSparse_time /* returns current wall clock time in seconds */ -( - void -) ; - -/* returns sqrt (x^2 + y^2), computed reliably */ -double SuiteSparse_hypot (double x, double y) ; - -/* complex division of c = a/b */ -int SuiteSparse_divcomplex -( - double ar, double ai, /* real and imaginary parts of a */ - double br, double bi, /* real and imaginary parts of b */ - double *cr, double *ci /* real and imaginary parts of c */ -) ; - -/* determine which timer to use, if any */ -#ifndef NTIMER -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >= 199309L -#define SUITESPARSE_TIMER_ENABLED -#endif -#endif -#endif - -/* SuiteSparse printf macro */ -#define SUITESPARSE_PRINTF(params) \ -{ \ - if (SuiteSparse_config.printf_func != NULL) \ - { \ - (void) (SuiteSparse_config.printf_func) params ; \ - } \ -} - -/* ========================================================================== */ -/* === SuiteSparse version ================================================== */ -/* ========================================================================== */ - -/* SuiteSparse is not a package itself, but a collection of packages, some of - * which must be used together (UMFPACK requires AMD, CHOLMOD requires AMD, - * COLAMD, CAMD, and CCOLAMD, etc). A version number is provided here for the - * collection itself, which is also the version number of SuiteSparse_config. - */ - -int SuiteSparse_version /* returns SUITESPARSE_VERSION */ -( - /* output, not defined on input. Not used if NULL. Returns - the three version codes in version [0..2]: - version [0] is SUITESPARSE_MAIN_VERSION - version [1] is SUITESPARSE_SUB_VERSION - version [2] is SUITESPARSE_SUBSUB_VERSION - */ - int version [3] -) ; - -/* Versions prior to 4.2.0 do not have the above function. The following - code fragment will work with any version of SuiteSparse: - - #ifdef SUITESPARSE_HAS_VERSION_FUNCTION - v = SuiteSparse_version (NULL) ; - #else - v = SUITESPARSE_VERSION ; - #endif -*/ -#define SUITESPARSE_HAS_VERSION_FUNCTION - -#endif /* end comment */ - -#define SUITESPARSE_DATE "Mar 3, 2021" -#define SUITESPARSE_VER_CODE(main,sub) ((main) * 1000 + (sub)) -#define SUITESPARSE_MAIN_VERSION 5 -#define SUITESPARSE_SUB_VERSION 9 -#define SUITESPARSE_SUBSUB_VERSION 0 -#define SUITESPARSE_VERSION \ - SUITESPARSE_VER_CODE(SUITESPARSE_MAIN_VERSION,SUITESPARSE_SUB_VERSION) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/vendor/cs/cs.h b/src/vendor/cs/cs.h deleted file mode 100644 index 0e58521e14f..00000000000 --- a/src/vendor/cs/cs.h +++ /dev/null @@ -1,758 +0,0 @@ -/* ========================================================================== */ -/* CXSparse/Include/cs.h file */ -/* ========================================================================== */ - -/* This is the CXSparse/Include/cs.h file. It has the same name (cs.h) as - the CSparse/Include/cs.h file. The 'make install' for SuiteSparse installs - CXSparse, and this file, instead of CSparse. The two packages have the same - cs.h include filename, because CXSparse is a superset of CSparse. Any user - program that uses CSparse can rely on CXSparse instead, with no change to the - user code. The #include "cs.h" line will work for both versions, in user - code, and the function names and user-visible typedefs from CSparse all - appear in CXSparse. For experimenting and changing the package itself, I - recommend using CSparse since it's simpler and easier to modify. For - using the package in production codes, I recommend CXSparse since it has - more features (support for complex matrices, and both int and long - versions). - */ - -/* ========================================================================== */ - -#ifndef _CXS_H -#define _CXS_H -#include -#include -#include -#include -#ifdef MATLAB_MEX_FILE -#include "mex.h" -#endif - - -#ifdef __cplusplus -#ifndef NCOMPLEX -#include -typedef std::complex cs_complex_t ; -#endif -extern "C" { -#else -#ifndef NCOMPLEX -#include -#define cs_complex_t double _Complex -#endif -#endif - -#define CS_VER 3 /* CXSparse Version */ -#define CS_SUBVER 2 -#define CS_SUBSUB 0 -#define CS_DATE "Sept 12, 2017" /* CSparse release date */ -#define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006-2016" -#define CXSPARSE - -#include "SuiteSparse_config.h" -#define cs_long_t SuiteSparse_long -#define cs_long_t_id SuiteSparse_long_id -#define cs_long_t_max SuiteSparse_long_max - -/* -------------------------------------------------------------------------- */ -/* double/int version of CXSparse */ -/* -------------------------------------------------------------------------- */ - -/* --- primary CSparse routines and data structures ------------------------- */ - -typedef struct cs_di_sparse /* matrix in compressed-column or triplet form */ -{ - int nzmax ; /* maximum number of entries */ - int m ; /* number of rows */ - int n ; /* number of columns */ - int *p ; /* column pointers (size n+1) or col indices (size nzmax) */ - int *i ; /* row indices, size nzmax */ - double *x ; /* numerical values, size nzmax */ - int nz ; /* # of entries in triplet matrix, -1 for compressed-col */ -} cs_di ; - -cs_di *cs_di_add (const cs_di *A, const cs_di *B, double alpha, double beta) ; -int cs_di_cholsol (int order, const cs_di *A, double *b) ; -int cs_di_dupl (cs_di *A) ; -int cs_di_entry (cs_di *T, int i, int j, double x) ; -int cs_di_lusol (int order, const cs_di *A, double *b, double tol) ; -int cs_di_gaxpy (const cs_di *A, const double *x, double *y) ; -cs_di *cs_di_multiply (const cs_di *A, const cs_di *B) ; -int cs_di_qrsol (int order, const cs_di *A, double *b) ; -cs_di *cs_di_transpose (const cs_di *A, int values) ; -cs_di *cs_di_compress (const cs_di *T) ; -double cs_di_norm (const cs_di *A) ; -/*int cs_di_print (const cs_di *A, int brief) ;*/ -cs_di *cs_di_load (FILE *f) ; - -/* utilities */ -void *cs_di_calloc (int n, size_t size) ; -void *cs_di_free (void *p) ; -void *cs_di_realloc (void *p, int n, size_t size, int *ok) ; -cs_di *cs_di_spalloc (int m, int n, int nzmax, int values, int t) ; -cs_di *cs_di_spfree (cs_di *A) ; -int cs_di_sprealloc (cs_di *A, int nzmax) ; -void *cs_di_malloc (int n, size_t size) ; - -/* --- secondary CSparse routines and data structures ----------------------- */ - -typedef struct cs_di_symbolic /* symbolic Cholesky, LU, or QR analysis */ -{ - int *pinv ; /* inverse row perm. for QR, fill red. perm for Chol */ - int *q ; /* fill-reducing column permutation for LU and QR */ - int *parent ; /* elimination tree for Cholesky and QR */ - int *cp ; /* column pointers for Cholesky, row counts for QR */ - int *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */ - int m2 ; /* # of rows for QR, after adding fictitious rows */ - double lnz ; /* # entries in L for LU or Cholesky; in V for QR */ - double unz ; /* # entries in U for LU; in R for QR */ -} cs_dis ; - -typedef struct cs_di_numeric /* numeric Cholesky, LU, or QR factorization */ -{ - cs_di *L ; /* L for LU and Cholesky, V for QR */ - cs_di *U ; /* U for LU, r for QR, not used for Cholesky */ - int *pinv ; /* partial pivoting for LU */ - double *B ; /* beta [0..n-1] for QR */ -} cs_din ; - -typedef struct cs_di_dmperm_results /* cs_di_dmperm or cs_di_scc output */ -{ - int *p ; /* size m, row permutation */ - int *q ; /* size n, column permutation */ - int *r ; /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */ - int *s ; /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */ - int nb ; /* # of blocks in fine dmperm decomposition */ - int rr [5] ; /* coarse row decomposition */ - int cc [5] ; /* coarse column decomposition */ -} cs_did ; - -int *cs_di_amd (int order, const cs_di *A) ; -cs_din *cs_di_chol (const cs_di *A, const cs_dis *S) ; -cs_did *cs_di_dmperm (const cs_di *A, int seed) ; -int cs_di_droptol (cs_di *A, double tol) ; -int cs_di_dropzeros (cs_di *A) ; -int cs_di_happly (const cs_di *V, int i, double beta, double *x) ; -int cs_di_ipvec (const int *p, const double *b, double *x, int n) ; -int cs_di_lsolve (const cs_di *L, double *x) ; -int cs_di_ltsolve (const cs_di *L, double *x) ; -cs_din *cs_di_lu (const cs_di *A, const cs_dis *S, double tol) ; -cs_di *cs_di_permute (const cs_di *A, const int *pinv, const int *q, - int values) ; -int *cs_di_pinv (const int *p, int n) ; -int cs_di_pvec (const int *p, const double *b, double *x, int n) ; -cs_din *cs_di_qr (const cs_di *A, const cs_dis *S) ; -cs_dis *cs_di_schol (int order, const cs_di *A) ; -cs_dis *cs_di_sqr (int order, const cs_di *A, int qr) ; -cs_di *cs_di_symperm (const cs_di *A, const int *pinv, int values) ; -int cs_di_usolve (const cs_di *U, double *x) ; -int cs_di_utsolve (const cs_di *U, double *x) ; -int cs_di_updown (cs_di *L, int sigma, const cs_di *C, const int *parent) ; - -/* utilities */ -cs_dis *cs_di_sfree (cs_dis *S) ; -cs_din *cs_di_nfree (cs_din *N) ; -cs_did *cs_di_dfree (cs_did *D) ; - -/* --- tertiary CSparse routines -------------------------------------------- */ - -int *cs_di_counts (const cs_di *A, const int *parent, const int *post, - int ata) ; -double cs_di_cumsum (int *p, int *c, int n) ; -int cs_di_dfs (int j, cs_di *G, int top, int *xi, int *pstack, - const int *pinv) ; -int *cs_di_etree (const cs_di *A, int ata) ; -int cs_di_fkeep (cs_di *A, int (*fkeep) (int, int, double, void *), - void *other) ; -double cs_di_house (double *x, double *beta, int n) ; -int *cs_di_maxtrans (const cs_di *A, int seed) ; -int *cs_di_post (const int *parent, int n) ; -cs_did *cs_di_scc (cs_di *A) ; -int cs_di_scatter (const cs_di *A, int j, double beta, int *w, double *x, - int mark, cs_di *C, int nz) ; -int cs_di_tdfs (int j, int k, int *head, const int *next, int *post, - int *stack) ; -int cs_di_leaf (int i, int j, const int *first, int *maxfirst, int *prevleaf, - int *ancestor, int *jleaf) ; -int cs_di_reach (cs_di *G, const cs_di *B, int k, int *xi, const int *pinv) ; -int cs_di_spsolve (cs_di *L, const cs_di *B, int k, int *xi, double *x, - const int *pinv, int lo) ; -int cs_di_ereach (const cs_di *A, int k, const int *parent, int *s, int *w) ; -int *cs_di_randperm (int n, int seed) ; - -/* utilities */ -cs_did *cs_di_dalloc (int m, int n) ; -cs_di *cs_di_done (cs_di *C, void *w, void *x, int ok) ; -int *cs_di_idone (int *p, cs_di *C, void *w, int ok) ; -cs_din *cs_di_ndone (cs_din *N, cs_di *C, void *w, void *x, int ok) ; -cs_did *cs_di_ddone (cs_did *D, cs_di *C, void *w, int ok) ; - - -/* -------------------------------------------------------------------------- */ -/* double/cs_long_t version of CXSparse */ -/* -------------------------------------------------------------------------- */ - -/* --- primary CSparse routines and data structures ------------------------- */ - -typedef struct cs_dl_sparse /* matrix in compressed-column or triplet form */ -{ - cs_long_t nzmax ; /* maximum number of entries */ - cs_long_t m ; /* number of rows */ - cs_long_t n ; /* number of columns */ - cs_long_t *p ; /* column pointers (size n+1) or col indlces (size nzmax) */ - cs_long_t *i ; /* row indices, size nzmax */ - double *x ; /* numerical values, size nzmax */ - cs_long_t nz ; /* # of entries in triplet matrix, -1 for compressed-col */ -} cs_dl ; - -cs_dl *cs_dl_add (const cs_dl *A, const cs_dl *B, double alpha, double beta) ; -cs_long_t cs_dl_cholsol (cs_long_t order, const cs_dl *A, double *b) ; -cs_long_t cs_dl_dupl (cs_dl *A) ; -cs_long_t cs_dl_entry (cs_dl *T, cs_long_t i, cs_long_t j, double x) ; -cs_long_t cs_dl_lusol (cs_long_t order, const cs_dl *A, double *b, double tol) ; -cs_long_t cs_dl_gaxpy (const cs_dl *A, const double *x, double *y) ; -cs_dl *cs_dl_multiply (const cs_dl *A, const cs_dl *B) ; -cs_long_t cs_dl_qrsol (cs_long_t order, const cs_dl *A, double *b) ; -cs_dl *cs_dl_transpose (const cs_dl *A, cs_long_t values) ; -cs_dl *cs_dl_compress (const cs_dl *T) ; -double cs_dl_norm (const cs_dl *A) ; -/*cs_long_t cs_dl_print (const cs_dl *A, cs_long_t brief) ;*/ -cs_dl *cs_dl_load (FILE *f) ; - -/* utilities */ -void *cs_dl_calloc (cs_long_t n, size_t size) ; -void *cs_dl_free (void *p) ; -void *cs_dl_realloc (void *p, cs_long_t n, size_t size, cs_long_t *ok) ; -cs_dl *cs_dl_spalloc (cs_long_t m, cs_long_t n, cs_long_t nzmax, cs_long_t values, - cs_long_t t) ; -cs_dl *cs_dl_spfree (cs_dl *A) ; -cs_long_t cs_dl_sprealloc (cs_dl *A, cs_long_t nzmax) ; -void *cs_dl_malloc (cs_long_t n, size_t size) ; - -/* --- secondary CSparse routines and data structures ----------------------- */ - -typedef struct cs_dl_symbolic /* symbolic Cholesky, LU, or QR analysis */ -{ - cs_long_t *pinv ; /* inverse row perm. for QR, fill red. perm for Chol */ - cs_long_t *q ; /* fill-reducing column permutation for LU and QR */ - cs_long_t *parent ; /* elimination tree for Cholesky and QR */ - cs_long_t *cp ; /* column pointers for Cholesky, row counts for QR */ - cs_long_t *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */ - cs_long_t m2 ; /* # of rows for QR, after adding fictitious rows */ - double lnz ; /* # entries in L for LU or Cholesky; in V for QR */ - double unz ; /* # entries in U for LU; in R for QR */ -} cs_dls ; - -typedef struct cs_dl_numeric /* numeric Cholesky, LU, or QR factorization */ -{ - cs_dl *L ; /* L for LU and Cholesky, V for QR */ - cs_dl *U ; /* U for LU, r for QR, not used for Cholesky */ - cs_long_t *pinv ; /* partial pivoting for LU */ - double *B ; /* beta [0..n-1] for QR */ -} cs_dln ; - -typedef struct cs_dl_dmperm_results /* cs_dl_dmperm or cs_dl_scc output */ -{ - cs_long_t *p ; /* size m, row permutation */ - cs_long_t *q ; /* size n, column permutation */ - cs_long_t *r ; /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */ - cs_long_t *s ; /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */ - cs_long_t nb ; /* # of blocks in fine dmperm decomposition */ - cs_long_t rr [5] ; /* coarse row decomposition */ - cs_long_t cc [5] ; /* coarse column decomposition */ -} cs_dld ; - -cs_long_t *cs_dl_amd (cs_long_t order, const cs_dl *A) ; -cs_dln *cs_dl_chol (const cs_dl *A, const cs_dls *S) ; -cs_dld *cs_dl_dmperm (const cs_dl *A, cs_long_t seed) ; -cs_long_t cs_dl_droptol (cs_dl *A, double tol) ; -cs_long_t cs_dl_dropzeros (cs_dl *A) ; -cs_long_t cs_dl_happly (const cs_dl *V, cs_long_t i, double beta, double *x) ; -cs_long_t cs_dl_ipvec (const cs_long_t *p, const double *b, double *x, cs_long_t n) ; -cs_long_t cs_dl_lsolve (const cs_dl *L, double *x) ; -cs_long_t cs_dl_ltsolve (const cs_dl *L, double *x) ; -cs_dln *cs_dl_lu (const cs_dl *A, const cs_dls *S, double tol) ; -cs_dl *cs_dl_permute (const cs_dl *A, const cs_long_t *pinv, const cs_long_t *q, - cs_long_t values) ; -cs_long_t *cs_dl_pinv (const cs_long_t *p, cs_long_t n) ; -cs_long_t cs_dl_pvec (const cs_long_t *p, const double *b, double *x, cs_long_t n) ; -cs_dln *cs_dl_qr (const cs_dl *A, const cs_dls *S) ; -cs_dls *cs_dl_schol (cs_long_t order, const cs_dl *A) ; -cs_dls *cs_dl_sqr (cs_long_t order, const cs_dl *A, cs_long_t qr) ; -cs_dl *cs_dl_symperm (const cs_dl *A, const cs_long_t *pinv, cs_long_t values) ; -cs_long_t cs_dl_usolve (const cs_dl *U, double *x) ; -cs_long_t cs_dl_utsolve (const cs_dl *U, double *x) ; -cs_long_t cs_dl_updown (cs_dl *L, cs_long_t sigma, const cs_dl *C, - const cs_long_t *parent) ; - -/* utilities */ -cs_dls *cs_dl_sfree (cs_dls *S) ; -cs_dln *cs_dl_nfree (cs_dln *N) ; -cs_dld *cs_dl_dfree (cs_dld *D) ; - -/* --- tertiary CSparse routines -------------------------------------------- */ - -cs_long_t *cs_dl_counts (const cs_dl *A, const cs_long_t *parent, - const cs_long_t *post, cs_long_t ata) ; -double cs_dl_cumsum (cs_long_t *p, cs_long_t *c, cs_long_t n) ; -cs_long_t cs_dl_dfs (cs_long_t j, cs_dl *G, cs_long_t top, cs_long_t *xi, - cs_long_t *pstack, const cs_long_t *pinv) ; -cs_long_t *cs_dl_etree (const cs_dl *A, cs_long_t ata) ; -cs_long_t cs_dl_fkeep (cs_dl *A, - cs_long_t (*fkeep) (cs_long_t, cs_long_t, double, void *), void *other) ; -double cs_dl_house (double *x, double *beta, cs_long_t n) ; -cs_long_t *cs_dl_maxtrans (const cs_dl *A, cs_long_t seed) ; -cs_long_t *cs_dl_post (const cs_long_t *parent, cs_long_t n) ; -cs_dld *cs_dl_scc (cs_dl *A) ; -cs_long_t cs_dl_scatter (const cs_dl *A, cs_long_t j, double beta, cs_long_t *w, - double *x, cs_long_t mark,cs_dl *C, cs_long_t nz) ; -cs_long_t cs_dl_tdfs (cs_long_t j, cs_long_t k, cs_long_t *head, const cs_long_t *next, - cs_long_t *post, cs_long_t *stack) ; -cs_long_t cs_dl_leaf (cs_long_t i, cs_long_t j, const cs_long_t *first, - cs_long_t *maxfirst, cs_long_t *prevleaf, cs_long_t *ancestor, cs_long_t *jleaf) ; -cs_long_t cs_dl_reach (cs_dl *G, const cs_dl *B, cs_long_t k, cs_long_t *xi, - const cs_long_t *pinv) ; -cs_long_t cs_dl_spsolve (cs_dl *L, const cs_dl *B, cs_long_t k, cs_long_t *xi, - double *x, const cs_long_t *pinv, cs_long_t lo) ; -cs_long_t cs_dl_ereach (const cs_dl *A, cs_long_t k, const cs_long_t *parent, - cs_long_t *s, cs_long_t *w) ; -cs_long_t *cs_dl_randperm (cs_long_t n, cs_long_t seed) ; - -/* utilities */ -cs_dld *cs_dl_dalloc (cs_long_t m, cs_long_t n) ; -cs_dl *cs_dl_done (cs_dl *C, void *w, void *x, cs_long_t ok) ; -cs_long_t *cs_dl_idone (cs_long_t *p, cs_dl *C, void *w, cs_long_t ok) ; -cs_dln *cs_dl_ndone (cs_dln *N, cs_dl *C, void *w, void *x, cs_long_t ok) ; -cs_dld *cs_dl_ddone (cs_dld *D, cs_dl *C, void *w, cs_long_t ok) ; - - -/* -------------------------------------------------------------------------- */ -/* complex/int version of CXSparse */ -/* -------------------------------------------------------------------------- */ - -#ifndef NCOMPLEX - -/* --- primary CSparse routines and data structures ------------------------- */ - -typedef struct cs_ci_sparse /* matrix in compressed-column or triplet form */ -{ - int nzmax ; /* maximum number of entries */ - int m ; /* number of rows */ - int n ; /* number of columns */ - int *p ; /* column pointers (size n+1) or col indices (size nzmax) */ - int *i ; /* row indices, size nzmax */ - cs_complex_t *x ; /* numerical values, size nzmax */ - int nz ; /* # of entries in triplet matrix, -1 for compressed-col */ -} cs_ci ; - -cs_ci *cs_ci_add (const cs_ci *A, const cs_ci *B, cs_complex_t alpha, - cs_complex_t beta) ; -int cs_ci_cholsol (int order, const cs_ci *A, cs_complex_t *b) ; -int cs_ci_dupl (cs_ci *A) ; -int cs_ci_entry (cs_ci *T, int i, int j, cs_complex_t x) ; -int cs_ci_lusol (int order, const cs_ci *A, cs_complex_t *b, double tol) ; -int cs_ci_gaxpy (const cs_ci *A, const cs_complex_t *x, cs_complex_t *y) ; -cs_ci *cs_ci_multiply (const cs_ci *A, const cs_ci *B) ; -int cs_ci_qrsol (int order, const cs_ci *A, cs_complex_t *b) ; -cs_ci *cs_ci_transpose (const cs_ci *A, int values) ; -cs_ci *cs_ci_compress (const cs_ci *T) ; -double cs_ci_norm (const cs_ci *A) ; -/*int cs_ci_print (const cs_ci *A, int brief) ;*/ -cs_ci *cs_ci_load (FILE *f) ; - -/* utilities */ -void *cs_ci_calloc (int n, size_t size) ; -void *cs_ci_free (void *p) ; -void *cs_ci_realloc (void *p, int n, size_t size, int *ok) ; -cs_ci *cs_ci_spalloc (int m, int n, int nzmax, int values, int t) ; -cs_ci *cs_ci_spfree (cs_ci *A) ; -int cs_ci_sprealloc (cs_ci *A, int nzmax) ; -void *cs_ci_malloc (int n, size_t size) ; - -/* --- secondary CSparse routines and data structures ----------------------- */ - -typedef struct cs_ci_symbolic /* symbolic Cholesky, LU, or QR analysis */ -{ - int *pinv ; /* inverse row perm. for QR, fill red. perm for Chol */ - int *q ; /* fill-reducing column permutation for LU and QR */ - int *parent ; /* elimination tree for Cholesky and QR */ - int *cp ; /* column pointers for Cholesky, row counts for QR */ - int *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */ - int m2 ; /* # of rows for QR, after adding fictitious rows */ - double lnz ; /* # entries in L for LU or Cholesky; in V for QR */ - double unz ; /* # entries in U for LU; in R for QR */ -} cs_cis ; - -typedef struct cs_ci_numeric /* numeric Cholesky, LU, or QR factorization */ -{ - cs_ci *L ; /* L for LU and Cholesky, V for QR */ - cs_ci *U ; /* U for LU, r for QR, not used for Cholesky */ - int *pinv ; /* partial pivoting for LU */ - double *B ; /* beta [0..n-1] for QR */ -} cs_cin ; - -typedef struct cs_ci_dmperm_results /* cs_ci_dmperm or cs_ci_scc output */ -{ - int *p ; /* size m, row permutation */ - int *q ; /* size n, column permutation */ - int *r ; /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */ - int *s ; /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */ - int nb ; /* # of blocks in fine dmperm decomposition */ - int rr [5] ; /* coarse row decomposition */ - int cc [5] ; /* coarse column decomposition */ -} cs_cid ; - -int *cs_ci_amd (int order, const cs_ci *A) ; -cs_cin *cs_ci_chol (const cs_ci *A, const cs_cis *S) ; -cs_cid *cs_ci_dmperm (const cs_ci *A, int seed) ; -int cs_ci_droptol (cs_ci *A, double tol) ; -int cs_ci_dropzeros (cs_ci *A) ; -int cs_ci_happly (const cs_ci *V, int i, double beta, cs_complex_t *x) ; -int cs_ci_ipvec (const int *p, const cs_complex_t *b, cs_complex_t *x, int n) ; -int cs_ci_lsolve (const cs_ci *L, cs_complex_t *x) ; -int cs_ci_ltsolve (const cs_ci *L, cs_complex_t *x) ; -cs_cin *cs_ci_lu (const cs_ci *A, const cs_cis *S, double tol) ; -cs_ci *cs_ci_permute (const cs_ci *A, const int *pinv, const int *q, - int values) ; -int *cs_ci_pinv (const int *p, int n) ; -int cs_ci_pvec (const int *p, const cs_complex_t *b, cs_complex_t *x, int n) ; -cs_cin *cs_ci_qr (const cs_ci *A, const cs_cis *S) ; -cs_cis *cs_ci_schol (int order, const cs_ci *A) ; -cs_cis *cs_ci_sqr (int order, const cs_ci *A, int qr) ; -cs_ci *cs_ci_symperm (const cs_ci *A, const int *pinv, int values) ; -int cs_ci_usolve (const cs_ci *U, cs_complex_t *x) ; -int cs_ci_utsolve (const cs_ci *U, cs_complex_t *x) ; -int cs_ci_updown (cs_ci *L, int sigma, const cs_ci *C, const int *parent) ; - -/* utilities */ -cs_cis *cs_ci_sfree (cs_cis *S) ; -cs_cin *cs_ci_nfree (cs_cin *N) ; -cs_cid *cs_ci_dfree (cs_cid *D) ; - -/* --- tertiary CSparse routines -------------------------------------------- */ - -int *cs_ci_counts (const cs_ci *A, const int *parent, const int *post, - int ata) ; -double cs_ci_cumsum (int *p, int *c, int n) ; -int cs_ci_dfs (int j, cs_ci *G, int top, int *xi, int *pstack, - const int *pinv) ; -int *cs_ci_etree (const cs_ci *A, int ata) ; -int cs_ci_fkeep (cs_ci *A, int (*fkeep) (int, int, cs_complex_t, void *), - void *other) ; -cs_complex_t cs_ci_house (cs_complex_t *x, double *beta, int n) ; -int *cs_ci_maxtrans (const cs_ci *A, int seed) ; -int *cs_ci_post (const int *parent, int n) ; -cs_cid *cs_ci_scc (cs_ci *A) ; -int cs_ci_scatter (const cs_ci *A, int j, cs_complex_t beta, int *w, - cs_complex_t *x, int mark,cs_ci *C, int nz) ; -int cs_ci_tdfs (int j, int k, int *head, const int *next, int *post, - int *stack) ; -int cs_ci_leaf (int i, int j, const int *first, int *maxfirst, int *prevleaf, - int *ancestor, int *jleaf) ; -int cs_ci_reach (cs_ci *G, const cs_ci *B, int k, int *xi, const int *pinv) ; -int cs_ci_spsolve (cs_ci *L, const cs_ci *B, int k, int *xi, - cs_complex_t *x, const int *pinv, int lo) ; -int cs_ci_ereach (const cs_ci *A, int k, const int *parent, int *s, int *w) ; -int *cs_ci_randperm (int n, int seed) ; - -/* utilities */ -cs_cid *cs_ci_dalloc (int m, int n) ; -cs_ci *cs_ci_done (cs_ci *C, void *w, void *x, int ok) ; -int *cs_ci_idone (int *p, cs_ci *C, void *w, int ok) ; -cs_cin *cs_ci_ndone (cs_cin *N, cs_ci *C, void *w, void *x, int ok) ; -cs_cid *cs_ci_ddone (cs_cid *D, cs_ci *C, void *w, int ok) ; - - -/* -------------------------------------------------------------------------- */ -/* complex/cs_long_t version of CXSparse */ -/* -------------------------------------------------------------------------- */ - -/* --- primary CSparse routines and data structures ------------------------- */ - -typedef struct cs_cl_sparse /* matrix in compressed-column or triplet form */ -{ - cs_long_t nzmax ; /* maximum number of entries */ - cs_long_t m ; /* number of rows */ - cs_long_t n ; /* number of columns */ - cs_long_t *p ; /* column pointers (size n+1) or col indlces (size nzmax) */ - cs_long_t *i ; /* row indices, size nzmax */ - cs_complex_t *x ; /* numerical values, size nzmax */ - cs_long_t nz ; /* # of entries in triplet matrix, -1 for compressed-col */ -} cs_cl ; - -cs_cl *cs_cl_add (const cs_cl *A, const cs_cl *B, cs_complex_t alpha, - cs_complex_t beta) ; -cs_long_t cs_cl_cholsol (cs_long_t order, const cs_cl *A, cs_complex_t *b) ; -cs_long_t cs_cl_dupl (cs_cl *A) ; -cs_long_t cs_cl_entry (cs_cl *T, cs_long_t i, cs_long_t j, cs_complex_t x) ; -cs_long_t cs_cl_lusol (cs_long_t order, const cs_cl *A, cs_complex_t *b, - double tol) ; -cs_long_t cs_cl_gaxpy (const cs_cl *A, const cs_complex_t *x, cs_complex_t *y) ; -cs_cl *cs_cl_multiply (const cs_cl *A, const cs_cl *B) ; -cs_long_t cs_cl_qrsol (cs_long_t order, const cs_cl *A, cs_complex_t *b) ; -cs_cl *cs_cl_transpose (const cs_cl *A, cs_long_t values) ; -cs_cl *cs_cl_compress (const cs_cl *T) ; -double cs_cl_norm (const cs_cl *A) ; -/*cs_long_t cs_cl_print (const cs_cl *A, cs_long_t brief) ;*/ -cs_cl *cs_cl_load (FILE *f) ; - -/* utilities */ -void *cs_cl_calloc (cs_long_t n, size_t size) ; -void *cs_cl_free (void *p) ; -void *cs_cl_realloc (void *p, cs_long_t n, size_t size, cs_long_t *ok) ; -cs_cl *cs_cl_spalloc (cs_long_t m, cs_long_t n, cs_long_t nzmax, cs_long_t values, - cs_long_t t) ; -cs_cl *cs_cl_spfree (cs_cl *A) ; -cs_long_t cs_cl_sprealloc (cs_cl *A, cs_long_t nzmax) ; -void *cs_cl_malloc (cs_long_t n, size_t size) ; - -/* --- secondary CSparse routines and data structures ----------------------- */ - -typedef struct cs_cl_symbolic /* symbolic Cholesky, LU, or QR analysis */ -{ - cs_long_t *pinv ; /* inverse row perm. for QR, fill red. perm for Chol */ - cs_long_t *q ; /* fill-reducing column permutation for LU and QR */ - cs_long_t *parent ; /* elimination tree for Cholesky and QR */ - cs_long_t *cp ; /* column pointers for Cholesky, row counts for QR */ - cs_long_t *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */ - cs_long_t m2 ; /* # of rows for QR, after adding fictitious rows */ - double lnz ; /* # entries in L for LU or Cholesky; in V for QR */ - double unz ; /* # entries in U for LU; in R for QR */ -} cs_cls ; - -typedef struct cs_cl_numeric /* numeric Cholesky, LU, or QR factorization */ -{ - cs_cl *L ; /* L for LU and Cholesky, V for QR */ - cs_cl *U ; /* U for LU, r for QR, not used for Cholesky */ - cs_long_t *pinv ; /* partial pivoting for LU */ - double *B ; /* beta [0..n-1] for QR */ -} cs_cln ; - -typedef struct cs_cl_dmperm_results /* cs_cl_dmperm or cs_cl_scc output */ -{ - cs_long_t *p ; /* size m, row permutation */ - cs_long_t *q ; /* size n, column permutation */ - cs_long_t *r ; /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */ - cs_long_t *s ; /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */ - cs_long_t nb ; /* # of blocks in fine dmperm decomposition */ - cs_long_t rr [5] ; /* coarse row decomposition */ - cs_long_t cc [5] ; /* coarse column decomposition */ -} cs_cld ; - -cs_long_t *cs_cl_amd (cs_long_t order, const cs_cl *A) ; -cs_cln *cs_cl_chol (const cs_cl *A, const cs_cls *S) ; -cs_cld *cs_cl_dmperm (const cs_cl *A, cs_long_t seed) ; -cs_long_t cs_cl_droptol (cs_cl *A, double tol) ; -cs_long_t cs_cl_dropzeros (cs_cl *A) ; -cs_long_t cs_cl_happly (const cs_cl *V, cs_long_t i, double beta, cs_complex_t *x) ; -cs_long_t cs_cl_ipvec (const cs_long_t *p, const cs_complex_t *b, - cs_complex_t *x, cs_long_t n) ; -cs_long_t cs_cl_lsolve (const cs_cl *L, cs_complex_t *x) ; -cs_long_t cs_cl_ltsolve (const cs_cl *L, cs_complex_t *x) ; -cs_cln *cs_cl_lu (const cs_cl *A, const cs_cls *S, double tol) ; -cs_cl *cs_cl_permute (const cs_cl *A, const cs_long_t *pinv, const cs_long_t *q, - cs_long_t values) ; -cs_long_t *cs_cl_pinv (const cs_long_t *p, cs_long_t n) ; -cs_long_t cs_cl_pvec (const cs_long_t *p, const cs_complex_t *b, - cs_complex_t *x, cs_long_t n) ; -cs_cln *cs_cl_qr (const cs_cl *A, const cs_cls *S) ; -cs_cls *cs_cl_schol (cs_long_t order, const cs_cl *A) ; -cs_cls *cs_cl_sqr (cs_long_t order, const cs_cl *A, cs_long_t qr) ; -cs_cl *cs_cl_symperm (const cs_cl *A, const cs_long_t *pinv, cs_long_t values) ; -cs_long_t cs_cl_usolve (const cs_cl *U, cs_complex_t *x) ; -cs_long_t cs_cl_utsolve (const cs_cl *U, cs_complex_t *x) ; -cs_long_t cs_cl_updown (cs_cl *L, cs_long_t sigma, const cs_cl *C, - const cs_long_t *parent) ; - -/* utilities */ -cs_cls *cs_cl_sfree (cs_cls *S) ; -cs_cln *cs_cl_nfree (cs_cln *N) ; -cs_cld *cs_cl_dfree (cs_cld *D) ; - -/* --- tertiary CSparse routines -------------------------------------------- */ - -cs_long_t *cs_cl_counts (const cs_cl *A, const cs_long_t *parent, - const cs_long_t *post, cs_long_t ata) ; -double cs_cl_cumsum (cs_long_t *p, cs_long_t *c, cs_long_t n) ; -cs_long_t cs_cl_dfs (cs_long_t j, cs_cl *G, cs_long_t top, cs_long_t *xi, - cs_long_t *pstack, const cs_long_t *pinv) ; -cs_long_t *cs_cl_etree (const cs_cl *A, cs_long_t ata) ; -cs_long_t cs_cl_fkeep (cs_cl *A, - cs_long_t (*fkeep) (cs_long_t, cs_long_t, cs_complex_t, void *), void *other) ; -cs_complex_t cs_cl_house (cs_complex_t *x, double *beta, cs_long_t n) ; -cs_long_t *cs_cl_maxtrans (const cs_cl *A, cs_long_t seed) ; -cs_long_t *cs_cl_post (const cs_long_t *parent, cs_long_t n) ; -cs_cld *cs_cl_scc (cs_cl *A) ; -cs_long_t cs_cl_scatter (const cs_cl *A, cs_long_t j, cs_complex_t beta, - cs_long_t *w, cs_complex_t *x, cs_long_t mark,cs_cl *C, cs_long_t nz) ; -cs_long_t cs_cl_tdfs (cs_long_t j, cs_long_t k, cs_long_t *head, const cs_long_t *next, - cs_long_t *post, cs_long_t *stack) ; -cs_long_t cs_cl_leaf (cs_long_t i, cs_long_t j, const cs_long_t *first, - cs_long_t *maxfirst, cs_long_t *prevleaf, cs_long_t *ancestor, cs_long_t *jleaf) ; -cs_long_t cs_cl_reach (cs_cl *G, const cs_cl *B, cs_long_t k, cs_long_t *xi, - const cs_long_t *pinv) ; -cs_long_t cs_cl_spsolve (cs_cl *L, const cs_cl *B, cs_long_t k, cs_long_t *xi, - cs_complex_t *x, const cs_long_t *pinv, cs_long_t lo) ; -cs_long_t cs_cl_ereach (const cs_cl *A, cs_long_t k, const cs_long_t *parent, - cs_long_t *s, cs_long_t *w) ; -cs_long_t *cs_cl_randperm (cs_long_t n, cs_long_t seed) ; - -/* utilities */ -cs_cld *cs_cl_dalloc (cs_long_t m, cs_long_t n) ; -cs_cl *cs_cl_done (cs_cl *C, void *w, void *x, cs_long_t ok) ; -cs_long_t *cs_cl_idone (cs_long_t *p, cs_cl *C, void *w, cs_long_t ok) ; -cs_cln *cs_cl_ndone (cs_cln *N, cs_cl *C, void *w, void *x, cs_long_t ok) ; -cs_cld *cs_cl_ddone (cs_cld *D, cs_cl *C, void *w, cs_long_t ok) ; - -#endif - -/* -------------------------------------------------------------------------- */ -/* Macros for constructing each version of CSparse */ -/* -------------------------------------------------------------------------- */ - -#ifdef CS_LONG -#define CS_INT cs_long_t -#define CS_INT_MAX cs_long_t_max -#define CS_ID cs_long_t_id -#ifdef CS_COMPLEX -#define CS_ENTRY cs_complex_t -#define CS_NAME(nm) cs_cl ## nm -#define cs cs_cl -#else -#define CS_ENTRY double -#define CS_NAME(nm) cs_dl ## nm -#define cs cs_dl -#endif -#else -#define CS_INT int -#define CS_INT_MAX INT_MAX -#define CS_ID "%d" -#ifdef CS_COMPLEX -#define CS_ENTRY cs_complex_t -#define CS_NAME(nm) cs_ci ## nm -#define cs cs_ci -#else -#define CS_ENTRY double -#define CS_NAME(nm) cs_di ## nm -#define cs cs_di -#endif -#endif - -#ifdef CS_COMPLEX -#define CS_REAL(x) creal(x) -#define CS_IMAG(x) cimag(x) -#define CS_CONJ(x) conj(x) -#define CS_ABS(x) cabs(x) -#else -#define CS_REAL(x) (x) -#define CS_IMAG(x) (0.) -#define CS_CONJ(x) (x) -#define CS_ABS(x) fabs(x) -#endif - -#define CS_MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define CS_MIN(a,b) (((a) < (b)) ? (a) : (b)) -#define CS_FLIP(i) (-(i)-2) -#define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i)) -#define CS_MARKED(w,j) (w [j] < 0) -#define CS_MARK(w,j) { w [j] = CS_FLIP (w [j]) ; } -#define CS_CSC(A) (A && (A->nz == -1)) -#define CS_TRIPLET(A) (A && (A->nz >= 0)) - -/* --- primary CSparse routines and data structures ------------------------- */ - -#define cs_add CS_NAME (_add) -#define cs_cholsol CS_NAME (_cholsol) -#define cs_dupl CS_NAME (_dupl) -#define cs_entry CS_NAME (_entry) -#define cs_lusol CS_NAME (_lusol) -#define cs_gaxpy CS_NAME (_gaxpy) -#define cs_multiply CS_NAME (_multiply) -#define cs_qrsol CS_NAME (_qrsol) -#define cs_transpose CS_NAME (_transpose) -#define cs_compress CS_NAME (_compress) -#define cs_norm CS_NAME (_norm) -/*#define cs_print CS_NAME (_print)*/ -#define cs_load CS_NAME (_load) - -/* utilities */ -#define cs_calloc CS_NAME (_calloc) -#define cs_free CS_NAME (_free) -#define cs_realloc CS_NAME (_realloc) -#define cs_spalloc CS_NAME (_spalloc) -#define cs_spfree CS_NAME (_spfree) -#define cs_sprealloc CS_NAME (_sprealloc) -#define cs_malloc CS_NAME (_malloc) - -/* --- secondary CSparse routines and data structures ----------------------- */ -#define css CS_NAME (s) -#define csn CS_NAME (n) -#define csd CS_NAME (d) - -#define cs_amd CS_NAME (_amd) -#define cs_chol CS_NAME (_chol) -#define cs_dmperm CS_NAME (_dmperm) -#define cs_droptol CS_NAME (_droptol) -#define cs_dropzeros CS_NAME (_dropzeros) -#define cs_happly CS_NAME (_happly) -#define cs_ipvec CS_NAME (_ipvec) -#define cs_lsolve CS_NAME (_lsolve) -#define cs_ltsolve CS_NAME (_ltsolve) -#define cs_lu CS_NAME (_lu) -#define cs_permute CS_NAME (_permute) -#define cs_pinv CS_NAME (_pinv) -#define cs_pvec CS_NAME (_pvec) -#define cs_qr CS_NAME (_qr) -#define cs_schol CS_NAME (_schol) -#define cs_sqr CS_NAME (_sqr) -#define cs_symperm CS_NAME (_symperm) -#define cs_usolve CS_NAME (_usolve) -#define cs_utsolve CS_NAME (_utsolve) -#define cs_updown CS_NAME (_updown) - -/* utilities */ -#define cs_sfree CS_NAME (_sfree) -#define cs_nfree CS_NAME (_nfree) -#define cs_dfree CS_NAME (_dfree) - -/* --- tertiary CSparse routines -------------------------------------------- */ -#define cs_counts CS_NAME (_counts) -#define cs_cumsum CS_NAME (_cumsum) -#define cs_dfs CS_NAME (_dfs) -#define cs_etree CS_NAME (_etree) -#define cs_fkeep CS_NAME (_fkeep) -#define cs_house CS_NAME (_house) -#define cs_invmatch CS_NAME (_invmatch) -#define cs_maxtrans CS_NAME (_maxtrans) -#define cs_post CS_NAME (_post) -#define cs_scc CS_NAME (_scc) -#define cs_scatter CS_NAME (_scatter) -#define cs_tdfs CS_NAME (_tdfs) -#define cs_reach CS_NAME (_reach) -#define cs_spsolve CS_NAME (_spsolve) -#define cs_ereach CS_NAME (_ereach) -#define cs_randperm CS_NAME (_randperm) -#define cs_leaf CS_NAME (_leaf) - -/* utilities */ -#define cs_dalloc CS_NAME (_dalloc) -#define cs_done CS_NAME (_done) -#define cs_idone CS_NAME (_idone) -#define cs_ndone CS_NAME (_ndone) -#define cs_ddone CS_NAME (_ddone) - -/* -------------------------------------------------------------------------- */ -/* Conversion routines */ -/* -------------------------------------------------------------------------- */ - -#ifndef NCOMPLEX -cs_di *cs_i_real (cs_ci *A, int real) ; -cs_ci *cs_i_complex (cs_di *A, int real) ; -cs_dl *cs_l_real (cs_cl *A, cs_long_t real) ; -cs_cl *cs_l_complex (cs_dl *A, cs_long_t real) ; -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/vendor/igraph_config.h b/src/vendor/igraph_config.h new file mode 100644 index 00000000000..ccd1297735a --- /dev/null +++ b/src/vendor/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 64 + +#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 int + +__END_DECLS + +#endif diff --git a/src/vendor/igraph_export.h b/src/vendor/igraph_export.h new file mode 100644 index 00000000000..508cb6eeede --- /dev/null +++ b/src/vendor/igraph_export.h @@ -0,0 +1,11 @@ + +#ifndef IGRAPH_EXPORT_H +#define IGRAPH_EXPORT_H + +#define IGRAPH_EXPORT +#define IGRAPH_NO_EXPORT +#define IGRAPH_DEPRECATED __attribute__ ((__deprecated__)) +#define IGRAPH_DEPRECATED_EXPORT IGRAPH_EXPORT IGRAPH_DEPRECATED +#define IGRAPH_DEPRECATED_NO_EXPORT IGRAPH_NO_EXPORT IGRAPH_DEPRECATED + +#endif /* IGRAPH_EXPORT_H */ diff --git a/src/vendor/igraph_threading.h b/src/vendor/igraph_threading.h new file mode 100644 index 00000000000..ebbdb1780c0 --- /dev/null +++ b/src/vendor/igraph_threading.h @@ -0,0 +1,47 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2011-2012 Gabor Csardi + 334 Harvard street, Cambridge, MA 02139 USA + + 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_THREADING_H +#define IGRAPH_THREADING_H + +#include "igraph_decls.h" + +__BEGIN_DECLS + +/** + * \define IGRAPH_THREAD_SAFE + * + * Specifies whether igraph was built in thread-safe mode. + * + * This macro is defined to 1 if the current build of the igraph library is + * built in thread-safe mode, and 0 if it is not. A thread-safe igraph library + * attempts to use thread-local data structures instead of global ones, but + * note that this is not (and can not) be guaranteed for third-party libraries + * that igraph links to. + */ + +#define IGRAPH_THREAD_SAFE 0 + +__END_DECLS + +#endif diff --git a/src/vendor/igraph_version.h b/src/vendor/igraph_version.h new file mode 100644 index 00000000000..fda42278d82 --- /dev/null +++ b/src/vendor/igraph_version.h @@ -0,0 +1,44 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2010-2012 Gabor Csardi + 334 Harvard street, Cambridge, MA 02139 USA + + 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_VERSION_H +#define IGRAPH_VERSION_H + +#include "igraph_decls.h" + +__BEGIN_DECLS + +#define IGRAPH_VERSION "@PACKAGE_VERSION@" +#define IGRAPH_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@ +#define IGRAPH_VERSION_MINOR @PACKAGE_VERSION_MINOR@ +#define IGRAPH_VERSION_PATCH @PACKAGE_VERSION_PATCH@ +#define IGRAPH_VERSION_PRERELEASE "@PACKAGE_VERSION_PRERELEASE@" + +IGRAPH_EXPORT void igraph_version(const char **version_string, + int *major, + int *minor, + int *subminor); + +__END_DECLS + +#endif diff --git a/src/vendor/io/gml-lexer.c b/src/vendor/io/gml-lexer.c index 39db98ba8e2..3a73d7ceab2 100644 --- a/src/vendor/io/gml-lexer.c +++ b/src/vendor/io/gml-lexer.c @@ -592,8 +592,8 @@ static void __attribute__((unused)) yy_fatal_error ( const char* msg , yyscan_t yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 10 -#define YY_END_OF_BUFFER 11 +#define YY_NUM_RULES 11 +#define YY_END_OF_BUFFER 12 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -601,12 +601,13 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[40] = +static const flex_int16_t yy_accept[43] = { 0, - 0, 0, 0, 0, 11, 9, 8, 8, 9, 9, - 4, 5, 6, 7, 1, 9, 5, 5, 0, 2, - 4, 0, 0, 5, 1, 0, 0, 5, 5, 4, - 0, 4, 0, 0, 3, 3, 3, 3, 0 + 0, 0, 0, 0, 12, 10, 8, 9, 9, 10, + 10, 4, 5, 6, 7, 1, 10, 5, 5, 8, + 9, 0, 2, 4, 0, 0, 5, 1, 0, 0, + 5, 5, 4, 0, 4, 0, 0, 3, 3, 3, + 3, 0 } ; static const YY_CHAR yy_ec[256] = @@ -648,58 +649,60 @@ static const YY_CHAR yy_meta[24] = 3, 3, 4 } ; -static const flex_int16_t yy_base[43] = +static const flex_int16_t yy_base[46] = { 0, - 0, 70, 17, 69, 74, 77, 77, 77, 68, 61, - 17, 0, 77, 77, 0, 30, 12, 18, 59, 77, - 34, 52, 46, 0, 0, 19, 31, 35, 41, 48, - 38, 26, 45, 44, 0, 0, 77, 77, 77, 66, - 28, 69 + 0, 78, 17, 77, 82, 85, 79, 23, 25, 74, + 63, 21, 0, 85, 85, 0, 30, 19, 25, 70, + 39, 66, 85, 40, 59, 47, 0, 0, 40, 47, + 45, 45, 50, 38, 37, 50, 52, 0, 0, 85, + 85, 85, 74, 34, 77 } ; -static const flex_int16_t yy_def[43] = +static const flex_int16_t yy_def[46] = { 0, - 39, 1, 1, 3, 39, 39, 39, 39, 40, 39, - 39, 41, 39, 39, 42, 39, 41, 41, 40, 39, - 39, 39, 39, 41, 42, 39, 39, 41, 41, 39, - 39, 39, 39, 39, 41, 41, 39, 39, 0, 39, - 39, 39 + 42, 1, 1, 3, 42, 42, 42, 42, 42, 43, + 42, 42, 44, 42, 42, 45, 42, 44, 44, 42, + 42, 43, 42, 42, 42, 42, 44, 45, 42, 42, + 44, 44, 42, 42, 42, 42, 42, 44, 44, 42, + 42, 0, 42, 42, 42 } ; -static const flex_int16_t yy_nxt[101] = +static const flex_int16_t yy_nxt[109] = { 0, - 6, 7, 8, 7, 9, 6, 10, 10, 6, 11, - 12, 12, 12, 12, 12, 12, 13, 14, 12, 12, - 12, 12, 6, 16, 16, 22, 21, 28, 29, 23, - 24, 17, 18, 28, 33, 32, 29, 17, 18, 21, - 33, 34, 22, 21, 26, 27, 23, 32, 35, 34, - 26, 27, 31, 31, 35, 32, 36, 30, 37, 38, - 23, 30, 36, 20, 37, 38, 19, 19, 19, 25, - 21, 25, 20, 39, 15, 15, 5, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39 - + 6, 7, 8, 9, 10, 6, 11, 11, 6, 12, + 13, 13, 13, 13, 13, 13, 14, 15, 13, 13, + 13, 13, 6, 17, 17, 21, 21, 21, 21, 25, + 24, 18, 19, 26, 31, 32, 27, 18, 19, 24, + 31, 21, 21, 32, 29, 30, 35, 35, 25, 24, + 29, 30, 26, 34, 34, 36, 35, 37, 38, 33, + 39, 36, 26, 40, 38, 37, 39, 41, 33, 40, + 23, 20, 24, 41, 22, 22, 22, 28, 23, 28, + 20, 42, 16, 16, 5, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + + 42, 42, 42, 42, 42, 42, 42, 42 } ; -static const flex_int16_t yy_chk[101] = +static const flex_int16_t yy_chk[109] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 3, 11, 11, 17, 18, 11, - 41, 3, 3, 17, 26, 32, 18, 3, 3, 16, - 26, 27, 21, 21, 16, 16, 21, 31, 28, 27, - 16, 16, 23, 23, 28, 23, 29, 30, 33, 34, - 30, 22, 29, 19, 33, 34, 40, 40, 40, 42, - 10, 42, 9, 5, 4, 2, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39 - + 1, 1, 1, 3, 3, 8, 8, 9, 9, 12, + 12, 3, 3, 12, 18, 19, 44, 3, 3, 17, + 18, 21, 21, 19, 17, 17, 35, 34, 24, 24, + 17, 17, 24, 26, 26, 29, 26, 30, 31, 33, + 32, 29, 33, 36, 31, 30, 32, 37, 25, 36, + 22, 20, 11, 37, 43, 43, 43, 45, 10, 45, + 7, 5, 4, 2, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + + 42, 42, 42, 42, 42, 42, 42, 42 } ; /* Table of booleans, true if rule could match eol. */ -static const flex_int32_t yy_rule_can_match_eol[11] = +static const flex_int32_t yy_rule_can_match_eol[12] = { 0, -0, 1, 0, 0, 0, 0, 0, 1, 0, 0, }; +0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -767,12 +770,12 @@ static const flex_int32_t yy_rule_can_match_eol[11] = #endif #define stdout 0 #endif -#line 771 "src/vendor/io/gml-lexer.c" +#line 774 "src/vendor/io/gml-lexer.c" #define YY_NO_INPUT 1 /* Use to parse inf/nan as number only when expecting a value, i.e. after a keyword. * Otherwise they are parsed as a keyword. */ -#line 776 "src/vendor/io/gml-lexer.c" +#line 779 "src/vendor/io/gml-lexer.c" #define INITIAL 0 #define VALUE 1 @@ -1058,10 +1061,10 @@ YY_DECL } { -#line 79 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 80 "src/vendor/cigraph/src/io/gml-lexer.l" -#line 1065 "src/vendor/io/gml-lexer.c" +#line 1068 "src/vendor/io/gml-lexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1089,13 +1092,13 @@ YY_DECL while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 40 ) + if ( yy_current_state >= 43 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 77 ); + while ( yy_base[yy_current_state] != 85 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1133,33 +1136,33 @@ YY_DECL case 1: YY_RULE_SETUP -#line 81 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 82 "src/vendor/cigraph/src/io/gml-lexer.l" { /* comments ignored */ } YY_BREAK case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 83 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 84 "src/vendor/cigraph/src/io/gml-lexer.l" { BEGIN(INITIAL); return STRING; } YY_BREAK case 3: YY_RULE_SETUP -#line 84 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 85 "src/vendor/cigraph/src/io/gml-lexer.l" { BEGIN(INITIAL); return NUM; } YY_BREAK case 4: YY_RULE_SETUP -#line 85 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 86 "src/vendor/cigraph/src/io/gml-lexer.l" { BEGIN(INITIAL); return NUM; } YY_BREAK case 5: YY_RULE_SETUP -#line 86 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 87 "src/vendor/cigraph/src/io/gml-lexer.l" { BEGIN(VALUE); return KEYWORD; } YY_BREAK case 6: YY_RULE_SETUP -#line 87 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 88 "src/vendor/cigraph/src/io/gml-lexer.l" { BEGIN(INITIAL); yyextra->depth++; @@ -1172,29 +1175,34 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 96 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 97 "src/vendor/cigraph/src/io/gml-lexer.l" { yyextra->depth--; return LISTCLOSE; } YY_BREAK case 8: -/* rule 8 can match eol */ YY_RULE_SETUP -#line 100 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 101 "src/vendor/cigraph/src/io/gml-lexer.l" { /* other whitespace ignored */ } YY_BREAK case 9: +/* rule 9 can match eol */ YY_RULE_SETUP #line 102 "src/vendor/cigraph/src/io/gml-lexer.l" -{ return ERROR; } +{ yy_set_bol(true); /* set "beginning of line" even after \r */ } YY_BREAK case 10: YY_RULE_SETUP -#line 103 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 104 "src/vendor/cigraph/src/io/gml-lexer.l" +{ return ERROR; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 105 "src/vendor/cigraph/src/io/gml-lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1198 "src/vendor/io/gml-lexer.c" +#line 1206 "src/vendor/io/gml-lexer.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(VALUE): yyterminate(); @@ -1495,7 +1503,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 40 ) + if ( yy_current_state >= 43 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1524,11 +1532,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 40 ) + if ( yy_current_state >= 43 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 39); + yy_is_jam = (yy_current_state == 42); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2358,6 +2366,6 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 103 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 105 "src/vendor/cigraph/src/io/gml-lexer.l" diff --git a/src/vendor/io/gml-parser.c b/src/vendor/io/gml-parser.c index 734210c6d49..4f846527273 100644 --- a/src/vendor/io/gml-parser.c +++ b/src/vendor/io/gml-parser.c @@ -131,10 +131,9 @@ static igraph_error_t igraph_i_gml_make_empty(igraph_gml_tree_t **tree); static igraph_error_t igraph_i_gml_merge(igraph_gml_tree_t *t1, igraph_gml_tree_t* t2); #define scanner context->scanner -#define USE(x) /*(x)*/ -#line 138 "yy.tab.c" +#line 137 "yy.tab.c" # ifndef YY_CAST # ifdef __cplusplus @@ -567,8 +566,8 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 122, 122, 124, 125, 126, 128, 130, 132, 136, - 139, 147 + 0, 121, 121, 123, 124, 125, 127, 129, 131, 135, + 138, 146 }; #endif @@ -1231,27 +1230,27 @@ yydestruct (const char *yymsg, switch (yykind) { case YYSYMBOL_list: /* list */ -#line 118 "src/vendor/cigraph/src/io/gml-parser.y" +#line 117 "src/vendor/cigraph/src/io/gml-parser.y" { igraph_gml_tree_destroy(((*yyvaluep).tree)); } -#line 1237 "yy.tab.c" +#line 1236 "yy.tab.c" break; case YYSYMBOL_keyvalue: /* keyvalue */ -#line 118 "src/vendor/cigraph/src/io/gml-parser.y" +#line 117 "src/vendor/cigraph/src/io/gml-parser.y" { igraph_gml_tree_destroy(((*yyvaluep).tree)); } -#line 1243 "yy.tab.c" +#line 1242 "yy.tab.c" break; case YYSYMBOL_key: /* key */ -#line 117 "src/vendor/cigraph/src/io/gml-parser.y" +#line 116 "src/vendor/cigraph/src/io/gml-parser.y" { free(((*yyvaluep).str)); } -#line 1249 "yy.tab.c" +#line 1248 "yy.tab.c" break; case YYSYMBOL_string: /* string */ -#line 117 "src/vendor/cigraph/src/io/gml-parser.y" +#line 116 "src/vendor/cigraph/src/io/gml-parser.y" { free(((*yyvaluep).str)); } -#line 1255 "yy.tab.c" +#line 1254 "yy.tab.c" break; default: @@ -1555,57 +1554,57 @@ YYLTYPE yylloc = yyloc_default; switch (yyn) { case 2: /* input: list */ -#line 122 "src/vendor/cigraph/src/io/gml-parser.y" +#line 121 "src/vendor/cigraph/src/io/gml-parser.y" { context->tree=(yyvsp[0].tree); } -#line 1561 "yy.tab.c" +#line 1560 "yy.tab.c" break; case 3: /* list: %empty */ -#line 124 "src/vendor/cigraph/src/io/gml-parser.y" +#line 123 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_make_empty(&(yyval.tree))); } -#line 1567 "yy.tab.c" +#line 1566 "yy.tab.c" break; case 4: /* list: keyvalue */ -#line 125 "src/vendor/cigraph/src/io/gml-parser.y" +#line 124 "src/vendor/cigraph/src/io/gml-parser.y" { (yyval.tree)=(yyvsp[0].tree); } -#line 1573 "yy.tab.c" +#line 1572 "yy.tab.c" break; case 5: /* list: list keyvalue */ -#line 126 "src/vendor/cigraph/src/io/gml-parser.y" +#line 125 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_merge((yyvsp[-1].tree), (yyvsp[0].tree))); (yyval.tree) = (yyvsp[-1].tree); } -#line 1579 "yy.tab.c" +#line 1578 "yy.tab.c" break; case 6: /* keyvalue: key num */ -#line 129 "src/vendor/cigraph/src/io/gml-parser.y" +#line 128 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_make_numeric((yyvsp[-1].str), (yylsp[-1]).first_line, (yyvsp[0].real), &(yyval.tree))); } -#line 1585 "yy.tab.c" +#line 1584 "yy.tab.c" break; case 7: /* keyvalue: key string */ -#line 131 "src/vendor/cigraph/src/io/gml-parser.y" +#line 130 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_make_string((yyvsp[-1].str), (yylsp[-1]).first_line, (yyvsp[0].str), &(yyval.tree))); } -#line 1591 "yy.tab.c" +#line 1590 "yy.tab.c" break; case 8: /* keyvalue: key "[" list "]" */ -#line 133 "src/vendor/cigraph/src/io/gml-parser.y" +#line 132 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_make_list((yyvsp[-3].str), (yylsp[-3]).first_line, (yyvsp[-1].tree), &(yyval.tree))); } -#line 1597 "yy.tab.c" +#line 1596 "yy.tab.c" break; case 9: /* key: "keyword" */ -#line 136 "src/vendor/cigraph/src/io/gml-parser.y" +#line 135 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_get_keyword(igraph_gml_yyget_text(scanner), igraph_gml_yyget_leng(scanner), - &(yyval.str))); USE((yyvsp[0].str)); } -#line 1605 "yy.tab.c" + &(yyval.str))); } +#line 1604 "yy.tab.c" break; case 10: /* num: "number" */ -#line 139 "src/vendor/cigraph/src/io/gml-parser.y" +#line 138 "src/vendor/cigraph/src/io/gml-parser.y" { igraph_real_t val; IGRAPH_YY_CHECK(igraph_i_parse_real(igraph_gml_yyget_text(scanner), @@ -1613,19 +1612,19 @@ YYLTYPE yylloc = yyloc_default; &val)); (yyval.real)=val; } -#line 1617 "yy.tab.c" +#line 1616 "yy.tab.c" break; case 11: /* string: "string" */ -#line 147 "src/vendor/cigraph/src/io/gml-parser.y" +#line 146 "src/vendor/cigraph/src/io/gml-parser.y" { IGRAPH_YY_CHECK(igraph_i_gml_get_string(igraph_gml_yyget_text(scanner), igraph_gml_yyget_leng(scanner), &(yyval.str))); } -#line 1625 "yy.tab.c" +#line 1624 "yy.tab.c" break; -#line 1629 "yy.tab.c" +#line 1628 "yy.tab.c" default: break; } @@ -1854,7 +1853,7 @@ YYLTYPE yylloc = yyloc_default; return yyresult; } -#line 151 "src/vendor/cigraph/src/io/gml-parser.y" +#line 150 "src/vendor/cigraph/src/io/gml-parser.y" int igraph_gml_yyerror(YYLTYPE* locp, igraph_i_gml_parsedata_t *context, diff --git a/src/vendor/io/lgl-lexer.c b/src/vendor/io/lgl-lexer.c index 338443fbe2b..9dfdc806383 100644 --- a/src/vendor/io/lgl-lexer.c +++ b/src/vendor/io/lgl-lexer.c @@ -601,10 +601,10 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[14] = +static const flex_int16_t yy_accept[16] = { 0, - 0, 0, 7, 4, 2, 3, 3, 1, 5, 4, - 2, 3, 0 + 0, 0, 0, 0, 7, 5, 1, 4, 4, 3, + 2, 1, 4, 3, 0 } ; static const YY_CHAR yy_ec[256] = @@ -612,66 +612,66 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 5, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 + 1, 2, 5, 5, 6, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5 } ; static const YY_CHAR yy_meta[7] = { 0, - 1, 2, 3, 4, 5, 5 + 1, 2, 3, 4, 5, 1 } ; -static const flex_int16_t yy_base[18] = +static const flex_int16_t yy_base[20] = { 0, - 0, 0, 11, 0, 0, 0, 0, 12, 12, 0, - 0, 12, 12, 9, 7, 4, 4 + 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, + 12, 0, 12, 0, 12, 8, 5, 5, 2 } ; -static const flex_int16_t yy_def[18] = +static const flex_int16_t yy_def[20] = { 0, - 13, 1, 13, 14, 15, 16, 17, 13, 13, 14, - 15, 13, 0, 13, 13, 13, 13 + 15, 1, 1, 1, 15, 15, 16, 17, 18, 19, + 15, 16, 15, 19, 0, 15, 15, 15, 15 } ; static const flex_int16_t yy_nxt[19] = { 0, - 4, 5, 6, 7, 8, 9, 12, 12, 11, 10, - 13, 3, 13, 13, 13, 13, 13, 13 + 6, 7, 8, 9, 10, 11, 14, 13, 13, 12, + 15, 5, 15, 15, 15, 15, 15, 15 } ; static const flex_int16_t yy_chk[19] = { 0, - 1, 1, 1, 1, 1, 1, 17, 16, 15, 14, - 3, 13, 13, 13, 13, 13, 13, 13 + 1, 1, 1, 1, 1, 1, 19, 18, 17, 16, + 5, 15, 15, 15, 15, 15, 15, 15 } ; /* Table of booleans, true if rule could match eol. */ static const flex_int32_t yy_rule_can_match_eol[7] = { 0, -0, 0, 1, 0, 0, 0, }; +0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -743,9 +743,12 @@ static const flex_int32_t yy_rule_can_match_eol[7] = #endif #line 745 "src/vendor/io/lgl-lexer.c" #define YY_NO_INPUT 1 -#line 747 "src/vendor/io/lgl-lexer.c" +/* Anything except non-printable (00-1F), space (20), del (7F) and # */ + +#line 749 "src/vendor/io/lgl-lexer.c" #define INITIAL 0 +#define LINE 1 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -1025,12 +1028,12 @@ YY_DECL } { -#line 76 "src/vendor/cigraph/src/io/lgl-lexer.l" +#line 79 "src/vendor/cigraph/src/io/lgl-lexer.l" -#line 79 "src/vendor/cigraph/src/io/lgl-lexer.l" - /* --------------------------------------------------hashmark------*/ -#line 1034 "src/vendor/io/lgl-lexer.c" +#line 82 "src/vendor/cigraph/src/io/lgl-lexer.l" + /* ------------------------------------------------whitespace------*/ +#line 1037 "src/vendor/io/lgl-lexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1057,7 +1060,7 @@ YY_DECL while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 14 ) + if ( yy_current_state >= 16 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1101,49 +1104,44 @@ YY_DECL case 1: YY_RULE_SETUP -#line 80 "src/vendor/cigraph/src/io/lgl-lexer.l" -{ return HASH; } - YY_BREAK -/* ------------------------------------------------whitespace------*/ -case 2: -YY_RULE_SETUP #line 83 "src/vendor/cigraph/src/io/lgl-lexer.l" -{ } +{ /* skip space */ } YY_BREAK -/* ---------------------------------------------------newline------*/ -case 3: -/* rule 3 can match eol */ +/* --------------------------------------------------hashmark------*/ +case 2: YY_RULE_SETUP #line 86 "src/vendor/cigraph/src/io/lgl-lexer.l" -{ return NEWLINE; } +{ BEGIN(LINE); return HASH; } YY_BREAK /* ----------------------------------------------alphanumeric------*/ -case 4: +case 3: YY_RULE_SETUP #line 89 "src/vendor/cigraph/src/io/lgl-lexer.l" -{ return ALNUM; } +{ BEGIN(LINE); return ALNUM; } YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 91 "src/vendor/cigraph/src/io/lgl-lexer.l" -{ if (yyextra->eof) { - yyterminate(); - } else { - yyextra->eof=1; - return NEWLINE; - } - } +/* ---------------------------------------------------newline------*/ +case 4: +/* rule 4 can match eol */ +#line 93 "src/vendor/cigraph/src/io/lgl-lexer.l" +YY_RULE_SETUP +case YY_STATE_EOF(LINE): +#line 93 "src/vendor/cigraph/src/io/lgl-lexer.l" +{ BEGIN(INITIAL); return NEWLINE; } YY_BREAK +/* ---------------------------------------------anything else------*/ case 5: YY_RULE_SETUP -#line 99 "src/vendor/cigraph/src/io/lgl-lexer.l" +#line 96 "src/vendor/cigraph/src/io/lgl-lexer.l" { return ERROR; } YY_BREAK case 6: YY_RULE_SETUP -#line 101 "src/vendor/cigraph/src/io/lgl-lexer.l" +#line 98 "src/vendor/cigraph/src/io/lgl-lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1147 "src/vendor/io/lgl-lexer.c" +#line 1143 "src/vendor/io/lgl-lexer.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); case YY_END_OF_BUFFER: { @@ -1431,7 +1429,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 6); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1440,7 +1438,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 14 ) + if ( yy_current_state >= 16 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1460,7 +1458,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ char *yy_cp = yyg->yy_c_buf_p; - YY_CHAR yy_c = 6; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1469,11 +1467,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 14 ) + if ( yy_current_state >= 16 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 13); + yy_is_jam = (yy_current_state == 15); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2302,6 +2300,6 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 101 "src/vendor/cigraph/src/io/lgl-lexer.l" +#line 98 "src/vendor/cigraph/src/io/lgl-lexer.l" diff --git a/src/vendor/io/lgl-parser.c b/src/vendor/io/lgl-parser.c index dcd19d6ec82..683482c4516 100644 --- a/src/vendor/io/lgl-parser.c +++ b/src/vendor/io/lgl-parser.c @@ -1799,4 +1799,3 @@ int igraph_lgl_yyerror(YYLTYPE* locp, igraph_i_lgl_parsedata_t *context, locp->first_line, s); return 0; } - diff --git a/src/vendor/io/ncol-lexer.c b/src/vendor/io/ncol-lexer.c index bc1f6ce2baf..a46f440ef63 100644 --- a/src/vendor/io/ncol-lexer.c +++ b/src/vendor/io/ncol-lexer.c @@ -601,10 +601,10 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[13] = +static const flex_int16_t yy_accept[15] = { 0, - 0, 0, 6, 3, 1, 2, 2, 4, 3, 1, - 2, 0 + 0, 0, 0, 0, 6, 4, 1, 3, 3, 2, + 1, 3, 2, 0 } ; static const YY_CHAR yy_ec[256] = @@ -612,31 +612,31 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 + 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5 } ; static const YY_CHAR yy_meta[6] = @@ -644,34 +644,34 @@ static const YY_CHAR yy_meta[6] = 1, 2, 3, 4, 5 } ; -static const flex_int16_t yy_base[17] = +static const flex_int16_t yy_base[19] = { 0, - 0, 0, 10, 0, 0, 0, 0, 11, 0, 0, - 11, 11, 8, 6, 3, 3 + 0, 0, 0, 0, 10, 11, 0, 0, 0, 0, + 0, 11, 0, 11, 7, 4, 4, 1 } ; -static const flex_int16_t yy_def[17] = +static const flex_int16_t yy_def[19] = { 0, - 12, 1, 12, 13, 14, 15, 16, 12, 13, 14, - 12, 0, 12, 12, 12, 12 + 14, 1, 1, 1, 14, 14, 15, 16, 17, 18, + 15, 14, 18, 0, 14, 14, 14, 14 } ; static const flex_int16_t yy_nxt[17] = { 0, - 4, 5, 6, 7, 8, 11, 11, 10, 9, 12, - 3, 12, 12, 12, 12, 12 + 6, 7, 8, 9, 10, 13, 12, 12, 11, 14, + 5, 14, 14, 14, 14, 14 } ; static const flex_int16_t yy_chk[17] = { 0, - 1, 1, 1, 1, 1, 16, 15, 14, 13, 3, - 12, 12, 12, 12, 12, 12 + 1, 1, 1, 1, 1, 18, 17, 16, 15, 5, + 14, 14, 14, 14, 14, 14 } ; /* Table of booleans, true if rule could match eol. */ static const flex_int32_t yy_rule_can_match_eol[6] = { 0, -0, 1, 0, 0, 0, }; +0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -743,9 +743,12 @@ static const flex_int32_t yy_rule_can_match_eol[6] = #endif #line 745 "src/vendor/io/ncol-lexer.c" #define YY_NO_INPUT 1 -#line 747 "src/vendor/io/ncol-lexer.c" +/* Anything except non-printable (00-1F), space (20) and del (7F) */ + +#line 749 "src/vendor/io/ncol-lexer.c" #define INITIAL 0 +#define LINE 1 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -1025,12 +1028,12 @@ YY_DECL } { -#line 76 "src/vendor/cigraph/src/io/ncol-lexer.l" +#line 79 "src/vendor/cigraph/src/io/ncol-lexer.l" -#line 79 "src/vendor/cigraph/src/io/ncol-lexer.l" +#line 82 "src/vendor/cigraph/src/io/ncol-lexer.l" /* ------------------------------------------------whitespace------*/ -#line 1034 "src/vendor/io/ncol-lexer.c" +#line 1037 "src/vendor/io/ncol-lexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1057,7 +1060,7 @@ YY_DECL while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 13 ) + if ( yy_current_state >= 15 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1101,44 +1104,38 @@ YY_DECL case 1: YY_RULE_SETUP -#line 80 "src/vendor/cigraph/src/io/ncol-lexer.l" -{ } - YY_BREAK -/* ---------------------------------------------------newline------*/ -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP #line 83 "src/vendor/cigraph/src/io/ncol-lexer.l" -{ return NEWLINE; } +{ /* skip space */ } YY_BREAK /* ----------------------------------------------alphanumeric------*/ -case 3: +case 2: YY_RULE_SETUP #line 86 "src/vendor/cigraph/src/io/ncol-lexer.l" -{ return ALNUM; } +{ BEGIN(LINE); return ALNUM; } YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 88 "src/vendor/cigraph/src/io/ncol-lexer.l" -{ if (yyextra->eof) { - yyterminate(); - } else { - yyextra->eof=1; - return NEWLINE; - } - } +/* ---------------------------------------------------newline------*/ +case 3: +/* rule 3 can match eol */ +#line 90 "src/vendor/cigraph/src/io/ncol-lexer.l" +YY_RULE_SETUP +case YY_STATE_EOF(LINE): +#line 90 "src/vendor/cigraph/src/io/ncol-lexer.l" +{ BEGIN(INITIAL); return NEWLINE; } YY_BREAK /* ---------------------------------------------anything else------*/ case 4: YY_RULE_SETUP -#line 97 "src/vendor/cigraph/src/io/ncol-lexer.l" +#line 93 "src/vendor/cigraph/src/io/ncol-lexer.l" { return ERROR; } YY_BREAK case 5: YY_RULE_SETUP -#line 99 "src/vendor/cigraph/src/io/ncol-lexer.l" +#line 95 "src/vendor/cigraph/src/io/ncol-lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1142 "src/vendor/io/ncol-lexer.c" +#line 1137 "src/vendor/io/ncol-lexer.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); case YY_END_OF_BUFFER: { @@ -1426,7 +1423,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 5); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1435,7 +1432,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 13 ) + if ( yy_current_state >= 15 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1455,7 +1452,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ char *yy_cp = yyg->yy_c_buf_p; - YY_CHAR yy_c = 5; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1464,11 +1461,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 13 ) + if ( yy_current_state >= 15 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 12); + yy_is_jam = (yy_current_state == 14); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2297,6 +2294,6 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 99 "src/vendor/cigraph/src/io/ncol-lexer.l" +#line 95 "src/vendor/cigraph/src/io/ncol-lexer.l" diff --git a/src/vendor/io/ncol-parser.c b/src/vendor/io/ncol-parser.c index 08f4f2cc242..3ccf6c0ad2a 100644 --- a/src/vendor/io/ncol-parser.c +++ b/src/vendor/io/ncol-parser.c @@ -153,8 +153,9 @@ enum yysymbol_kind_t YYSYMBOL_YYACCEPT = 6, /* $accept */ YYSYMBOL_input = 7, /* input */ YYSYMBOL_edge = 8, /* edge */ - YYSYMBOL_edgeid = 9, /* edgeid */ - YYSYMBOL_weight = 10 /* weight */ + YYSYMBOL_endpoints = 9, /* endpoints */ + YYSYMBOL_edgeid = 10, /* edgeid */ + YYSYMBOL_weight = 11 /* weight */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -485,16 +486,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 10 +#define YYLAST 7 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 6 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 5 +#define YYNNTS 6 /* YYNRULES -- Number of rules. */ -#define YYNRULES 8 +#define YYNRULES 9 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 12 +#define YYNSTATES 13 /* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 260 @@ -544,7 +545,7 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int8 yyrline[] = { - 0, 92, 92, 93, 94, 97, 102, 110, 120 + 0, 92, 92, 93, 94, 97, 100, 106, 111, 121 }; #endif @@ -561,8 +562,8 @@ static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; static const char *const yytname[] = { "\"end of file\"", "error", "\"invalid token\"", "\"alphanumeric\"", - "\"end of line\"", "ERROR", "$accept", "input", "edge", "edgeid", - "weight", YY_NULLPTR + "\"end of line\"", "ERROR", "$accept", "input", "edge", "endpoints", + "edgeid", "weight", YY_NULLPTR }; static const char * @@ -586,8 +587,8 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int8 yypact[] = { - -3, 0, -3, -3, -3, -3, 2, -2, -3, -3, - 3, -3 + -3, 0, -3, -3, -3, -3, -2, 2, -3, -3, + 3, -3, -3 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -595,20 +596,20 @@ static const yytype_int8 yypact[] = means the default is an error. */ static const yytype_int8 yydefact[] = { - 2, 0, 1, 7, 3, 4, 0, 0, 8, 5, - 0, 6 + 2, 0, 1, 8, 3, 4, 0, 0, 9, 5, + 0, 7, 6 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -3, -3, -3, 4, -3 + -3, -3, -3, -3, -1, -3 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - 0, 1, 5, 6, 10 + 0, 1, 5, 6, 7, 10 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -616,34 +617,32 @@ static const yytype_int8 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int8 yytable[] = { - 2, 8, 9, 3, 4, 3, 0, 11, 0, 0, - 7 + 2, 8, 9, 3, 4, 3, 11, 12 }; static const yytype_int8 yycheck[] = { - 0, 3, 4, 3, 4, 3, -1, 4, -1, -1, - 6 + 0, 3, 4, 3, 4, 3, 7, 4 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { - 0, 7, 0, 3, 4, 8, 9, 9, 3, 4, - 10, 4 + 0, 7, 0, 3, 4, 8, 9, 10, 3, 4, + 11, 10, 4 }; /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ static const yytype_int8 yyr1[] = { - 0, 6, 7, 7, 7, 8, 8, 9, 10 + 0, 6, 7, 7, 7, 8, 8, 9, 10, 11 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ static const yytype_int8 yyr2[] = { - 0, 2, 0, 2, 2, 3, 4, 1, 1 + 0, 2, 0, 2, 2, 2, 3, 2, 1, 1 }; @@ -1500,29 +1499,34 @@ YYLTYPE yylloc = yyloc_default; YY_REDUCE_PRINT (yyn); switch (yyn) { - case 5: /* edge: edgeid edgeid "end of line" */ + case 5: /* edge: endpoints "end of line" */ #line 97 "src/vendor/cigraph/src/io/ncol-parser.y" - { - IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-2].edgenum))); - IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-1].edgenum))); + { IGRAPH_YY_CHECK(igraph_vector_push_back(context->weights, 0.0)); } -#line 1511 "yy.tab.c" +#line 1508 "yy.tab.c" break; - case 6: /* edge: edgeid edgeid weight "end of line" */ -#line 102 "src/vendor/cigraph/src/io/ncol-parser.y" - { - IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-3].edgenum))); - IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-2].edgenum))); + case 6: /* edge: endpoints weight "end of line" */ +#line 100 "src/vendor/cigraph/src/io/ncol-parser.y" + { IGRAPH_YY_CHECK(igraph_vector_push_back(context->weights, (yyvsp[-1].weightnum))); - context->has_weights = 1; + context->has_weights = true; } -#line 1522 "yy.tab.c" +#line 1517 "yy.tab.c" break; - case 7: /* edgeid: "alphanumeric" */ -#line 110 "src/vendor/cigraph/src/io/ncol-parser.y" + case 7: /* endpoints: edgeid edgeid */ +#line 106 "src/vendor/cigraph/src/io/ncol-parser.y" + { + IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-1].edgenum))); + IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[0].edgenum))); +} +#line 1526 "yy.tab.c" + break; + + case 8: /* edgeid: "alphanumeric" */ +#line 111 "src/vendor/cigraph/src/io/ncol-parser.y" { igraph_integer_t trie_id; IGRAPH_YY_CHECK(igraph_trie_get_len(context->trie, @@ -1532,11 +1536,11 @@ YYLTYPE yylloc = yyloc_default; )); (yyval.edgenum) = trie_id; } -#line 1536 "yy.tab.c" +#line 1540 "yy.tab.c" break; - case 8: /* weight: "alphanumeric" */ -#line 120 "src/vendor/cigraph/src/io/ncol-parser.y" + case 9: /* weight: "alphanumeric" */ +#line 121 "src/vendor/cigraph/src/io/ncol-parser.y" { igraph_real_t val; IGRAPH_YY_CHECK(igraph_i_parse_real(igraph_ncol_yyget_text(scanner), @@ -1544,11 +1548,11 @@ YYLTYPE yylloc = yyloc_default; &val)); (yyval.weightnum)=val; } -#line 1548 "yy.tab.c" +#line 1552 "yy.tab.c" break; -#line 1552 "yy.tab.c" +#line 1556 "yy.tab.c" default: break; } @@ -1777,7 +1781,7 @@ YYLTYPE yylloc = yyloc_default; return yyresult; } -#line 128 "src/vendor/cigraph/src/io/ncol-parser.y" +#line 129 "src/vendor/cigraph/src/io/ncol-parser.y" int igraph_ncol_yyerror(YYLTYPE* locp, diff --git a/src/vendor/io/pajek-lexer.c b/src/vendor/io/pajek-lexer.c index 95d822e638e..07bcbd156cc 100644 --- a/src/vendor/io/pajek-lexer.c +++ b/src/vendor/io/pajek-lexer.c @@ -592,8 +592,8 @@ static void __attribute__((unused)) yy_fatal_error ( const char* msg , yyscan_t yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 48 -#define YY_END_OF_BUFFER 49 +#define YY_NUM_RULES 57 +#define YY_END_OF_BUFFER 58 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -601,243 +601,230 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[162] = +static const flex_int16_t yy_accept[161] = { 0, - 0, 0, 0, 0, 49, 46, 1, 12, 12, 46, - 2, 46, 46, 46, 15, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 47, 1, 46, 1, 12, 46, 0, 13, 2, - 2, 2, 46, 0, 14, 46, 46, 46, 46, 46, - 15, 46, 46, 29, 46, 46, 46, 46, 46, 26, - 46, 46, 46, 46, 46, 46, 38, 46, 46, 46, - 46, 27, 46, 23, 22, 28, 46, 46, 30, 46, - 46, 5, 1, 13, 14, 46, 46, 46, 46, 46, - 15, 46, 15, 33, 34, 37, 19, 20, 46, 46, - - 31, 32, 18, 35, 36, 43, 41, 39, 46, 42, - 46, 46, 46, 46, 46, 46, 46, 46, 3, 46, - 46, 45, 46, 21, 46, 25, 46, 46, 7, 46, - 46, 46, 46, 24, 40, 44, 46, 46, 46, 8, - 46, 46, 46, 46, 46, 46, 46, 11, 46, 46, - 16, 17, 46, 46, 4, 46, 9, 46, 6, 10, - 0 + 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, + 0, 0, 58, 56, 8, 17, 17, 55, 56, 55, + 19, 55, 56, 4, 5, 5, 4, 3, 6, 6, + 2, 2, 2, 2, 55, 55, 55, 55, 55, 24, + 23, 55, 55, 55, 40, 38, 55, 55, 55, 47, + 39, 41, 37, 8, 17, 55, 0, 18, 19, 55, + 55, 0, 7, 7, 55, 16, 16, 16, 16, 16, + 16, 4, 4, 5, 6, 6, 0, 26, 27, 55, + 25, 29, 28, 55, 30, 55, 55, 55, 55, 42, + 44, 46, 55, 35, 36, 43, 45, 52, 51, 48, + + 49, 19, 55, 19, 7, 16, 16, 16, 16, 16, + 1, 55, 32, 55, 22, 34, 55, 55, 55, 53, + 55, 16, 16, 16, 16, 16, 33, 31, 55, 55, + 54, 50, 11, 16, 16, 16, 16, 55, 55, 16, + 12, 16, 16, 16, 20, 21, 16, 16, 15, 16, + 16, 16, 16, 9, 16, 13, 16, 10, 14, 0 } ; static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 4, 4, 5, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 6, 1, 1, 7, 1, 1, 8, - 9, 10, 11, 1, 12, 13, 1, 14, 15, 16, - 14, 14, 14, 14, 14, 14, 14, 1, 1, 1, - 1, 1, 1, 1, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 1, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 1, 1, 1, 1, 42, 1, 43, 44, 45, 46, - - 47, 48, 49, 50, 51, 1, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 + 1, 2, 5, 6, 5, 5, 7, 5, 5, 5, + 5, 8, 9, 5, 10, 11, 5, 12, 13, 14, + 12, 12, 12, 12, 12, 12, 12, 5, 5, 5, + 5, 5, 5, 5, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 5, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 5, + 5, 5, 5, 5, 39, 5, 40, 41, 42, 43, + + 44, 45, 46, 47, 48, 5, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 5, 5, 5, 5, 5, 1, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 64, 5, 5, 5, + 65, 5, 5, 5, 5, 5, 5, 5, 5, 5, + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 66, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5 } ; -static const YY_CHAR yy_meta[69] = +static const YY_CHAR yy_meta[68] = { 0, - 1, 2, 3, 2, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 4 + 1, 2, 3, 3, 4, 2, 4, 2, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 5 } ; -static const flex_int16_t yy_base[171] = +static const flex_int16_t yy_base[172] = { 0, - 0, 0, 67, 71, 145, 0, 75, 75, 78, 82, - 87, 91, 80, 88, 97, 117, 86, 123, 84, 83, - 96, 91, 173, 134, 144, 149, 154, 83, 158, 96, - 88, 443, 151, 0, 160, 162, 166, 123, 0, 178, - 182, 183, 191, 112, 0, 140, 157, 172, 170, 176, - 198, 193, 210, 443, 226, 231, 235, 239, 244, 443, - 214, 248, 252, 256, 260, 265, 443, 270, 274, 278, - 282, 443, 176, 443, 443, 443, 211, 229, 443, 238, - 242, 0, 287, 443, 443, 247, 248, 253, 258, 261, - 284, 292, 295, 443, 443, 443, 443, 443, 260, 310, - - 443, 443, 443, 443, 443, 443, 443, 443, 271, 443, - 321, 280, 327, 299, 300, 284, 304, 300, 296, 300, - 334, 443, 343, 443, 347, 443, 319, 321, 314, 313, - 328, 324, 330, 443, 443, 443, 321, 322, 333, 335, - 324, 332, 349, 367, 372, 337, 351, 0, 352, 364, - 443, 443, 351, 353, 0, 356, 0, 357, 0, 0, - 443, 418, 81, 422, 425, 428, 431, 433, 436, 439 + 0, 67, 15, 23, 31, 35, 18, 26, 134, 33, + 201, 35, 337, 392, 331, 328, 328, 0, 243, 32, + 39, 53, 69, 237, 208, 197, 0, 392, 196, 0, + 392, 178, 392, 94, 30, 32, 45, 99, 42, 0, + 0, 47, 93, 86, 97, 0, 65, 35, 86, 152, + 0, 0, 0, 115, 392, 0, 109, 392, 252, 93, + 164, 119, 108, 98, 232, 0, 63, 90, 109, 108, + 112, 95, 0, 392, 84, 0, 0, 0, 0, 134, + 0, 0, 0, 123, 0, 137, 137, 175, 179, 0, + 0, 0, 190, 0, 0, 0, 0, 0, 0, 197, + + 0, 240, 215, 260, 392, 214, 211, 212, 227, 230, + 392, 234, 0, 246, 0, 0, 260, 261, 244, 0, + 255, 247, 261, 250, 246, 250, 0, 0, 270, 271, + 0, 0, 264, 258, 268, 265, 272, 264, 265, 276, + 284, 273, 280, 300, 0, 0, 287, 298, 0, 301, + 307, 294, 296, 0, 297, 0, 297, 0, 0, 392, + 355, 360, 365, 370, 3, 375, 378, 1, 381, 384, + 387 } ; -static const flex_int16_t yy_def[171] = +static const flex_int16_t yy_def[172] = { 0, - 161, 1, 162, 162, 161, 163, 161, 161, 161, 164, - 165, 166, 163, 163, 163, 163, 163, 163, 163, 163, - 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, - 163, 161, 167, 163, 161, 161, 164, 168, 163, 165, - 169, 161, 166, 170, 163, 163, 163, 163, 163, 163, - 163, 163, 163, 161, 163, 163, 163, 163, 163, 161, - 163, 163, 163, 163, 163, 163, 161, 163, 163, 163, - 163, 161, 163, 161, 161, 161, 163, 163, 161, 163, - 163, 167, 167, 161, 161, 163, 163, 163, 163, 163, - 163, 163, 163, 161, 161, 161, 161, 161, 163, 163, - - 161, 161, 161, 161, 161, 161, 161, 161, 163, 161, - 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, - 163, 161, 163, 161, 163, 161, 163, 163, 163, 163, - 163, 163, 163, 161, 161, 161, 163, 163, 163, 163, - 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, - 161, 161, 163, 163, 163, 163, 163, 163, 163, 163, - 0, 161, 161, 161, 161, 161, 161, 161, 161, 161 + 161, 161, 162, 162, 163, 163, 164, 164, 161, 9, + 161, 11, 160, 160, 160, 160, 160, 165, 166, 165, + 165, 167, 168, 169, 160, 160, 169, 160, 170, 170, + 160, 160, 160, 160, 165, 165, 165, 165, 165, 165, + 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, + 165, 165, 165, 160, 160, 165, 166, 160, 165, 165, + 165, 171, 160, 160, 167, 168, 168, 168, 168, 168, + 168, 169, 169, 160, 170, 170, 160, 165, 165, 165, + 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, + 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, + + 165, 165, 165, 165, 160, 168, 168, 168, 168, 168, + 160, 165, 165, 165, 165, 165, 165, 165, 165, 165, + 165, 168, 168, 168, 168, 168, 165, 165, 165, 165, + 165, 165, 168, 168, 168, 168, 168, 165, 165, 168, + 168, 168, 168, 168, 165, 165, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 0, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160 } ; -static const flex_int16_t yy_nxt[512] = +static const flex_int16_t yy_nxt[460] = { 0, - 6, 7, 8, 7, 9, 10, 11, 12, 6, 13, - 14, 14, 6, 15, 15, 15, 16, 17, 18, 6, - 6, 19, 6, 20, 21, 22, 23, 6, 6, 6, - 24, 25, 26, 27, 6, 28, 6, 29, 30, 31, - 6, 6, 16, 17, 18, 6, 6, 19, 6, 20, - 21, 22, 23, 6, 6, 6, 24, 25, 26, 27, - 6, 28, 6, 29, 30, 31, 6, 32, 33, 8, - 33, 9, 33, 8, 33, 9, 35, 36, 35, 36, - 36, 34, 36, 38, 38, 38, 38, 39, 41, 42, - 41, 42, 44, 44, 44, 44, 46, 62, 63, 45, - - 47, 51, 51, 51, 58, 65, 66, 48, 49, 52, - 51, 51, 51, 61, 64, 78, 50, 53, 54, 54, - 85, 54, 46, 59, 60, 60, 47, 60, 84, 81, - 58, 55, 56, 48, 49, 72, 72, 80, 72, 61, - 64, 78, 50, 53, 161, 74, 74, 57, 74, 59, - 75, 75, 83, 75, 83, 76, 76, 73, 76, 79, - 79, 35, 79, 35, 36, 161, 36, 38, 38, 38, - 38, 39, 86, 57, 67, 67, 87, 67, 77, 41, - 42, 41, 42, 73, 42, 42, 42, 42, 88, 68, - 89, 69, 44, 44, 44, 44, 90, 161, 86, 45, - - 111, 161, 87, 70, 77, 71, 91, 91, 91, 161, - 52, 51, 51, 51, 88, 68, 89, 69, 53, 161, - 92, 92, 90, 93, 93, 93, 111, 94, 94, 70, - 94, 71, 95, 95, 161, 95, 96, 96, 161, 96, - 97, 97, 99, 97, 53, 98, 98, 100, 98, 101, - 101, 112, 101, 102, 102, 113, 102, 103, 103, 114, - 103, 104, 104, 115, 104, 116, 105, 105, 99, 105, - 117, 106, 106, 100, 106, 107, 107, 112, 107, 108, - 108, 113, 108, 110, 110, 114, 110, 118, 83, 115, - 83, 116, 119, 120, 121, 123, 117, 91, 91, 91, - - 125, 109, 161, 161, 53, 93, 93, 93, 93, 93, - 93, 122, 122, 118, 122, 127, 128, 129, 119, 120, - 121, 123, 124, 124, 130, 124, 125, 109, 126, 126, - 53, 126, 131, 132, 133, 134, 134, 137, 134, 138, - 139, 127, 128, 129, 135, 135, 140, 135, 136, 136, - 130, 136, 141, 142, 143, 144, 145, 146, 131, 132, - 133, 147, 148, 137, 149, 138, 139, 150, 151, 151, - 153, 151, 140, 152, 152, 154, 152, 155, 141, 142, - 143, 144, 145, 146, 156, 157, 158, 147, 148, 159, - 149, 160, 161, 150, 161, 161, 153, 161, 161, 161, - - 161, 154, 161, 155, 161, 161, 161, 161, 161, 161, - 156, 157, 158, 161, 161, 159, 161, 160, 32, 32, - 32, 32, 37, 37, 37, 40, 40, 40, 43, 43, - 43, 82, 82, 38, 38, 38, 41, 41, 41, 44, - 44, 44, 5, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161 + 14, 15, 16, 17, 66, 19, 56, 14, 20, 20, + 160, 21, 21, 21, 160, 14, 24, 25, 26, 32, + 33, 160, 14, 14, 24, 25, 26, 32, 33, 160, + 28, 14, 29, 25, 26, 14, 29, 25, 26, 22, + 23, 22, 23, 59, 59, 59, 78, 94, 95, 60, + 59, 59, 59, 160, 62, 63, 64, 61, 62, 80, + 62, 81, 160, 86, 111, 79, 14, 14, 15, 16, + 17, 78, 19, 22, 23, 20, 20, 87, 21, 21, + 21, 14, 61, 67, 80, 75, 81, 68, 86, 14, + 79, 34, 93, 106, 69, 70, 72, 14, 96, 97, + + 105, 14, 87, 71, 102, 102, 102, 107, 67, 90, + 91, 105, 68, 82, 58, 83, 54, 93, 106, 69, + 70, 63, 64, 108, 89, 92, 109, 84, 71, 85, + 110, 88, 107, 14, 14, 15, 16, 17, 82, 19, + 83, 14, 20, 20, 114, 21, 21, 21, 108, 35, + 92, 109, 84, 36, 85, 110, 37, 77, 38, 115, + 112, 116, 39, 40, 41, 113, 98, 42, 99, 114, + 43, 44, 103, 103, 35, 104, 104, 104, 36, 54, + 100, 37, 101, 38, 115, 112, 116, 39, 40, 41, + 113, 98, 42, 99, 117, 43, 44, 75, 118, 74, + + 14, 14, 15, 16, 17, 100, 19, 101, 14, 20, + 20, 74, 21, 21, 21, 45, 119, 46, 121, 117, + 47, 120, 48, 118, 49, 50, 104, 104, 104, 51, + 122, 123, 52, 62, 63, 64, 53, 62, 72, 62, + 45, 119, 46, 121, 124, 47, 120, 48, 58, 49, + 50, 102, 102, 102, 51, 122, 123, 52, 61, 125, + 126, 53, 60, 59, 59, 59, 127, 14, 128, 124, + 61, 104, 104, 104, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 61, 125, 126, 138, 139, 140, 141, + 142, 127, 143, 128, 144, 61, 145, 146, 147, 129, + + 130, 131, 132, 133, 134, 135, 136, 137, 148, 149, + 150, 138, 139, 140, 141, 142, 151, 143, 152, 144, + 153, 145, 146, 147, 154, 155, 156, 157, 158, 159, + 55, 55, 54, 148, 149, 150, 160, 160, 160, 160, + 160, 151, 160, 152, 160, 153, 160, 160, 160, 154, + 155, 156, 157, 158, 159, 18, 18, 18, 18, 18, + 27, 27, 27, 27, 27, 30, 30, 30, 30, 30, + 31, 31, 31, 31, 31, 57, 57, 160, 57, 65, + 65, 65, 73, 160, 73, 76, 160, 76, 62, 62, + 62, 13, 160, 160, 160, 160, 160, 160, 160, 160, + + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160 } ; -static const flex_int16_t yy_chk[512] = +static const flex_int16_t yy_chk[460] = { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, - 3, 3, 4, 4, 4, 4, 7, 8, 7, 8, - 9, 163, 9, 10, 10, 10, 10, 10, 11, 11, - 11, 11, 12, 12, 12, 12, 13, 20, 20, 12, - - 13, 14, 14, 14, 17, 22, 22, 13, 13, 15, - 15, 15, 15, 19, 21, 28, 13, 15, 16, 16, - 44, 16, 13, 17, 18, 18, 13, 18, 38, 31, - 17, 16, 16, 13, 13, 24, 24, 30, 24, 19, - 21, 28, 13, 15, 5, 25, 25, 16, 25, 17, - 26, 26, 33, 26, 33, 27, 27, 24, 27, 29, - 29, 35, 29, 35, 36, 0, 36, 37, 37, 37, - 37, 37, 46, 16, 23, 23, 47, 23, 27, 40, - 40, 40, 40, 24, 41, 42, 41, 42, 48, 23, - 49, 23, 43, 43, 43, 43, 50, 0, 46, 43, - - 73, 0, 47, 23, 27, 23, 52, 52, 52, 0, - 51, 51, 51, 51, 48, 23, 49, 23, 51, 0, - 53, 53, 50, 53, 53, 53, 73, 55, 55, 23, - 55, 23, 56, 56, 0, 56, 57, 57, 0, 57, - 58, 58, 61, 58, 51, 59, 59, 61, 59, 62, - 62, 77, 62, 63, 63, 78, 63, 64, 64, 80, - 64, 65, 65, 81, 65, 86, 66, 66, 61, 66, - 87, 68, 68, 61, 68, 69, 69, 77, 69, 70, - 70, 78, 70, 71, 71, 80, 71, 88, 83, 81, - 83, 86, 89, 90, 99, 109, 87, 91, 91, 91, - - 112, 70, 0, 0, 91, 92, 92, 92, 93, 93, - 93, 100, 100, 88, 100, 114, 115, 116, 89, 90, - 99, 109, 111, 111, 117, 111, 112, 70, 113, 113, - 91, 113, 118, 119, 120, 121, 121, 127, 121, 128, - 129, 114, 115, 116, 123, 123, 130, 123, 125, 125, - 117, 125, 131, 132, 133, 137, 138, 139, 118, 119, - 120, 140, 141, 127, 142, 128, 129, 143, 144, 144, - 146, 144, 130, 145, 145, 147, 145, 149, 131, 132, - 133, 137, 138, 139, 150, 153, 154, 140, 141, 156, - 142, 158, 0, 143, 0, 0, 146, 0, 0, 0, - - 0, 147, 0, 149, 0, 0, 0, 0, 0, 0, - 150, 153, 154, 0, 0, 156, 0, 158, 162, 162, - 162, 162, 164, 164, 164, 165, 165, 165, 166, 166, - 166, 167, 167, 168, 168, 168, 169, 169, 169, 170, - 170, 170, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161 + 1, 1, 1, 1, 168, 1, 165, 1, 1, 1, + 0, 1, 1, 1, 0, 3, 3, 3, 3, 7, + 7, 0, 3, 4, 4, 4, 4, 8, 8, 0, + 4, 5, 5, 5, 5, 6, 6, 6, 6, 10, + 10, 12, 12, 20, 20, 20, 35, 48, 48, 21, + 21, 21, 21, 0, 22, 22, 22, 21, 22, 36, + 22, 37, 0, 39, 77, 35, 1, 2, 2, 2, + 2, 35, 2, 2, 2, 2, 2, 42, 2, 2, + 2, 3, 21, 23, 36, 75, 37, 23, 39, 4, + 35, 8, 47, 67, 23, 23, 72, 5, 49, 49, + + 64, 6, 42, 23, 60, 60, 60, 68, 23, 45, + 45, 63, 23, 38, 57, 38, 54, 47, 67, 23, + 23, 62, 62, 69, 44, 45, 70, 38, 23, 38, + 71, 43, 68, 2, 9, 9, 9, 9, 38, 9, + 38, 9, 9, 9, 84, 9, 9, 9, 69, 9, + 45, 70, 38, 9, 38, 71, 9, 34, 9, 86, + 80, 87, 9, 9, 9, 80, 50, 9, 50, 84, + 9, 9, 61, 61, 9, 61, 61, 61, 9, 32, + 50, 9, 50, 9, 86, 80, 87, 9, 9, 9, + 80, 50, 9, 50, 88, 9, 9, 29, 89, 26, + + 9, 11, 11, 11, 11, 50, 11, 50, 11, 11, + 11, 25, 11, 11, 11, 11, 93, 11, 100, 88, + 11, 93, 11, 89, 11, 11, 103, 103, 103, 11, + 106, 107, 11, 65, 65, 65, 11, 65, 24, 65, + 11, 93, 11, 100, 108, 11, 93, 11, 19, 11, + 11, 102, 102, 102, 11, 106, 107, 11, 102, 109, + 110, 11, 59, 59, 59, 59, 112, 11, 114, 108, + 59, 104, 104, 104, 117, 118, 119, 121, 122, 123, + 124, 125, 126, 102, 109, 110, 129, 130, 133, 134, + 135, 112, 136, 114, 137, 59, 138, 139, 140, 117, + + 118, 119, 121, 122, 123, 124, 125, 126, 141, 142, + 143, 129, 130, 133, 134, 135, 144, 136, 147, 137, + 148, 138, 139, 140, 150, 151, 152, 153, 155, 157, + 17, 16, 15, 141, 142, 143, 13, 0, 0, 0, + 0, 144, 0, 147, 0, 148, 0, 0, 0, 150, + 151, 152, 153, 155, 157, 161, 161, 161, 161, 161, + 162, 162, 162, 162, 162, 163, 163, 163, 163, 163, + 164, 164, 164, 164, 164, 166, 166, 0, 166, 167, + 167, 167, 169, 0, 169, 170, 0, 170, 171, 171, + 171, 160, 160, 160, 160, 160, 160, 160, 160, 160, + + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160 } ; /* Table of booleans, true if rule could match eol. */ -static const flex_int32_t yy_rule_can_match_eol[49] = +static const flex_int32_t yy_rule_can_match_eol[58] = { 0, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, }; +0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -900,6 +887,7 @@ static const flex_int32_t yy_rule_can_match_eol[49] = #define YY_EXTRA_TYPE igraph_i_pajek_parsedata_t* #define YY_USER_ACTION yylloc->first_line = yylineno; #define YY_FATAL_ERROR(msg) IGRAPH_FATAL("Error in Pajek parser: " # msg) +#define YY_USER_INIT BEGIN(bom) /* we start in the 'bom' start condition */ #ifdef USING_R #define fprintf(file, msg, ...) (1) #ifdef stdout @@ -907,13 +895,30 @@ static const flex_int32_t yy_rule_can_match_eol[49] = #endif #define stdout 0 #endif -#line 911 "src/vendor/io/pajek-lexer.c" +#line 899 "src/vendor/io/pajek-lexer.c" #define YY_NO_INPUT 1 - -#line 914 "src/vendor/io/pajek-lexer.c" +/* Any use of {newline} below must use yy_set_bol(true) in order to mark the character + following a single \r as the first on a new line, and allow the ^ pattern to match. + This pattern must match single newlines only, in order to follow Pajek's "no newline + after *Vertices" convention. */ +/* Anything except non-printable (00-1F), space (20), del (7F), '"' and '*'. */ +/* 'unknown' skips text at the beginning of the file, lines below an unknown *Word + * 'unknown_line' skips the rest of the line after an unknown *Word. */ + +/* Notes: + * - Unquoted '*' characters may only appear at the start of a line-initial word. + * - Both LF and CR LF line endings are allowed. + * - Pajek files do not allow empty lines after *Vertices (empty lines should signify the end of the file), + * therefore we are careful not to skip newlines in the lexer. + */ +#line 915 "src/vendor/io/pajek-lexer.c" #define INITIAL 0 -#define netline 1 +#define unknown 1 +#define unknown_line 2 +#define bom 3 +#define vert 4 +#define edge 5 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -1151,6 +1156,9 @@ extern int yylex \ #endif #define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /** The main scanner function which does all the work. @@ -1193,10 +1201,12 @@ YY_DECL } { -#line 81 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 104 "src/vendor/cigraph/src/io/pajek-lexer.l" -#line 1200 "src/vendor/io/pajek-lexer.c" +#line 107 "src/vendor/cigraph/src/io/pajek-lexer.l" + /* Skip a UTF-8 BOM at the very beginning of the file, if present, then immediately switch to 'unknown'. */ +#line 1210 "src/vendor/io/pajek-lexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1211,6 +1221,7 @@ YY_DECL yy_bp = yy_cp; yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); yy_match: do { @@ -1223,13 +1234,13 @@ YY_DECL while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 162 ) + if ( yy_current_state >= 161 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 443 ); + while ( yy_base[yy_current_state] != 392 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1267,418 +1278,318 @@ YY_DECL case 1: YY_RULE_SETUP -#line 83 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 108 "src/vendor/cigraph/src/io/pajek-lexer.l" { } YY_BREAK case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 84 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ } /* comments */ +#line 109 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(unknown); yyless(0); yy_set_bol(true); } YY_BREAK +/* Skip all text until the next *Word at the beginning of a line. */ case 3: YY_RULE_SETUP -#line 85 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ BEGIN(netline); return NETWORKLINE; } +#line 112 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(INITIAL); yyless(0); yy_set_bol(true); } YY_BREAK case 4: YY_RULE_SETUP -#line 86 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ BEGIN(netline); return NETWORKLINE; } +#line 113 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ } /* match cannot start with a * in order not to take precedence over ^\* above */ YY_BREAK case 5: +/* rule 5 can match eol */ YY_RULE_SETUP -#line 87 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ - return NET_TITLE; } +#line 114 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ yy_set_bol(true); } YY_BREAK case 6: YY_RULE_SETUP -#line 89 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return VERTICESLINE; } +#line 115 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(unknown); } YY_BREAK case 7: +/* rule 7 can match eol */ YY_RULE_SETUP -#line 90 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return ARCSLINE; } +#line 117 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ yy_set_bol(true); } /* comments */ YY_BREAK case 8: YY_RULE_SETUP -#line 91 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return EDGESLINE; } +#line 119 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ } YY_BREAK case 9: YY_RULE_SETUP -#line 92 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return ARCSLISTLINE; } +#line 121 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(unknown_line); return NETWORKLINE; } YY_BREAK case 10: YY_RULE_SETUP -#line 93 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return EDGESLISTLINE; } +#line 123 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(vert); return VERTICESLINE; } YY_BREAK case 11: YY_RULE_SETUP -#line 94 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return MATRIXLINE; } +#line 124 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(edge); return ARCSLINE; } YY_BREAK case 12: -/* rule 12 can match eol */ YY_RULE_SETUP -#line 95 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ BEGIN(INITIAL); yyextra->mode=0; return NEWLINE; } /* skip over multiple newlines */ +#line 125 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(edge); return EDGESLINE; } YY_BREAK case 13: -/* rule 13 can match eol */ YY_RULE_SETUP -#line 96 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return QSTR; } +#line 126 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(INITIAL); return ARCSLISTLINE; } YY_BREAK case 14: -/* rule 14 can match eol */ YY_RULE_SETUP -#line 97 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ return PSTR; } +#line 127 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(INITIAL);return EDGESLISTLINE; } YY_BREAK case 15: YY_RULE_SETUP -#line 98 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ - return NUM; } +#line 128 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(INITIAL); return MATRIXLINE; } YY_BREAK case 16: -/* rule 16 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 6); -yyg->yy_c_buf_p = yy_cp = yy_bp + 6; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 101 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_X_FACT; } else { return ALNUM; } } +#line 130 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ BEGIN(unknown_line); IGRAPH_WARNINGF("Skipping unknown section '%s' on line %d.", yytext, yylineno); } YY_BREAK case 17: /* rule 17 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 6); -yyg->yy_c_buf_p = yy_cp = yy_bp + 6; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 102 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_Y_FACT; } else { return ALNUM; } } +#line 132 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ yy_set_bol(true); return NEWLINE; } YY_BREAK +/* Newlines not allowed in strings. */ case 18: -/* rule 18 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 103 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_IC; } else { return ALNUM; } } +#line 135 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return QSTR; } YY_BREAK case 19: -/* rule 19 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 104 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_BC; } else { return ALNUM; } } +#line 137 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return NUM; } YY_BREAK + +/* http://mrvar.fdv.uni-lj.si/pajek/DrawEPS.htm */ case 20: -/* rule 20 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 105 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_BW; } else { return ALNUM; } } +#line 141 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_X_FACT; } YY_BREAK case 21: -/* rule 21 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 3); -yyg->yy_c_buf_p = yy_cp = yy_bp + 3; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 106 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_PHI; } else { return ALNUM; } } +#line 142 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_Y_FACT; } YY_BREAK case 22: -/* rule 22 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 107 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_R; } else { return ALNUM; } } +#line 143 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_PHI; } YY_BREAK case 23: -/* rule 23 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 108 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_Q; } else { return ALNUM; } } +#line 144 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_R; } YY_BREAK case 24: -/* rule 24 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 4); -yyg->yy_c_buf_p = yy_cp = yy_bp + 4; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 109 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_FONT; } else { return ALNUM; } } +#line 145 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_Q; } YY_BREAK case 25: -/* rule 25 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 3); -yyg->yy_c_buf_p = yy_cp = yy_bp + 3; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 110 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_URL; } else { return ALNUM; } } +#line 146 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_IC; } YY_BREAK case 26: -/* rule 26 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 112 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_C; } else { return ALNUM; } } +#line 147 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_BC; } YY_BREAK case 27: -/* rule 27 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 113 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_P; } else { return ALNUM; } } +#line 148 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_BW; } YY_BREAK case 28: -/* rule 28 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 114 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_S; } else { return ALNUM; } } +#line 149 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_LC; } YY_BREAK case 29: -/* rule 29 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 115 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_A; } else { return ALNUM; } } +#line 150 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_LA; } YY_BREAK case 30: -/* rule 30 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 116 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_W; } else { return ALNUM; } } +#line 151 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_LR; } YY_BREAK case 31: -/* rule 31 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 117 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_H1; } else { return ALNUM; } } +#line 152 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_LPHI; } YY_BREAK case 32: -/* rule 32 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 118 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_H2; } else { return ALNUM; } } +#line 153 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_FOS; } YY_BREAK case 33: -/* rule 33 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 119 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_A1; } else { return ALNUM; } } +#line 154 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_FONT; } YY_BREAK +/* http://mrvar.fdv.uni-lj.si/pajek/history.htm */ case 34: -/* rule 34 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 120 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_A2; } else { return ALNUM; } } +#line 156 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return VP_URL; } YY_BREAK + + +/* http://mrvar.fdv.uni-lj.si/pajek/DrawEPS.htm */ case 35: -/* rule 35 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 121 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_K1; } else { return ALNUM; } } +#line 161 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_H1; } YY_BREAK case 36: -/* rule 36 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 122 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_K2; } else { return ALNUM; } } +#line 162 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_H2; } YY_BREAK case 37: -/* rule 37 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 123 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_AP; } else { return ALNUM; } } +#line 163 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_W; } YY_BREAK case 38: -/* rule 38 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 1); -yyg->yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 124 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_L; } else { return ALNUM; } } +#line 164 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_C; } YY_BREAK case 39: -/* rule 39 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 125 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==2) { return EP_LP; } else { return ALNUM; } } +#line 165 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_P; } YY_BREAK case 40: -/* rule 40 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 4); -yyg->yy_c_buf_p = yy_cp = yy_bp + 4; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 127 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_LPHI; } else - if (yyextra->mode==2) { return EP_LPHI; } else { return ALNUM; } } +#line 166 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_A; } YY_BREAK case 41: -/* rule 41 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 129 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_LC; } else - if (yyextra->mode==2) { return EP_LC; } else { return ALNUM; } } +#line 167 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_S; } YY_BREAK case 42: -/* rule 42 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 131 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_LR; } else - if (yyextra->mode==2) { return EP_LR; } else { return ALNUM; } } +#line 168 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_A1; } YY_BREAK case 43: -/* rule 43 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 2); -yyg->yy_c_buf_p = yy_cp = yy_bp + 2; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 133 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_LA; } else - if (yyextra->mode==2) { return EP_LA; } else { return ALNUM; } } +#line 169 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_K1; } YY_BREAK case 44: -/* rule 44 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 4); -yyg->yy_c_buf_p = yy_cp = yy_bp + 4; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 135 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_SIZE; } else - if (yyextra->mode==2) { return EP_SIZE; } else { return ALNUM; } } +#line 170 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_A2; } YY_BREAK case 45: -/* rule 45 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -YY_LINENO_REWIND_TO(yy_bp + 3); -yyg->yy_c_buf_p = yy_cp = yy_bp + 3; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 137 "src/vendor/cigraph/src/io/pajek-lexer.l" -{ if (yyextra->mode==1) { return VP_FOS; } else - if (yyextra->mode==2) { return EP_FOS; } else { return ALNUM; } } +#line 171 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_K2; } YY_BREAK case 46: YY_RULE_SETUP -#line 140 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 172 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_AP; } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 173 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_L; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 174 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_LP; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 175 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_LR; } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 176 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_LPHI; } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 177 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_LC; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 178 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_LA; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 179 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_FOS; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 180 "src/vendor/cigraph/src/io/pajek-lexer.l" +{ return EP_FONT; } + YY_BREAK + +case 55: +YY_RULE_SETUP +#line 183 "src/vendor/cigraph/src/io/pajek-lexer.l" { return ALNUM; } YY_BREAK case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(netline): -#line 142 "src/vendor/cigraph/src/io/pajek-lexer.l" +case YY_STATE_EOF(unknown): +case YY_STATE_EOF(unknown_line): +case YY_STATE_EOF(bom): +case YY_STATE_EOF(vert): +case YY_STATE_EOF(edge): +#line 185 "src/vendor/cigraph/src/io/pajek-lexer.l" { if (yyextra->eof) { yyterminate(); } else { - yyextra->eof=1; + yyextra->eof=true; return NEWLINE; } } YY_BREAK -case 47: +case 56: YY_RULE_SETUP -#line 150 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 193 "src/vendor/cigraph/src/io/pajek-lexer.l" { return ERROR; } YY_BREAK -case 48: +case 57: YY_RULE_SETUP -#line 152 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 195 "src/vendor/cigraph/src/io/pajek-lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1682 "src/vendor/io/pajek-lexer.c" +#line 1593 "src/vendor/io/pajek-lexer.c" case YY_END_OF_BUFFER: { @@ -1963,10 +1874,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 68); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 67); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1975,7 +1887,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 162 ) + if ( yy_current_state >= 161 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1995,7 +1907,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ char *yy_cp = yyg->yy_c_buf_p; - YY_CHAR yy_c = 68; + YY_CHAR yy_c = 67; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -2004,11 +1916,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 162 ) + if ( yy_current_state >= 161 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 161); + yy_is_jam = (yy_current_state == 160); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2089,7 +2001,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; - if ( c == '\n' ) + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) do{ yylineno++; yycolumn=0; @@ -2837,6 +2750,6 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 152 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 195 "src/vendor/cigraph/src/io/pajek-lexer.l" diff --git a/src/vendor/io/pajek-parser.c b/src/vendor/io/pajek-parser.c index 28f0b65ba29..8c2ae84e062 100644 --- a/src/vendor/io/pajek-parser.c +++ b/src/vendor/io/pajek-parser.c @@ -116,27 +116,27 @@ int igraph_pajek_yyerror(YYLTYPE* locp, igraph_i_pajek_parsedata_t *context, const char *s); -static igraph_error_t igraph_i_pajek_add_string_vertex_attribute(const char *name, +static igraph_error_t add_string_vertex_attribute(const char *name, const char *value, size_t len, igraph_i_pajek_parsedata_t *context); -static igraph_error_t igraph_i_pajek_add_string_edge_attribute(const char *name, +static igraph_error_t add_string_edge_attribute(const char *name, const char *value, size_t len, igraph_i_pajek_parsedata_t *context); -static igraph_error_t igraph_i_pajek_add_numeric_vertex_attribute(const char *name, +static igraph_error_t add_numeric_vertex_attribute(const char *name, igraph_real_t value, igraph_i_pajek_parsedata_t *context); -static igraph_error_t igraph_i_pajek_add_numeric_edge_attribute(const char *name, +static igraph_error_t add_numeric_edge_attribute(const char *name, igraph_real_t value, igraph_i_pajek_parsedata_t *context); -static igraph_error_t igraph_i_pajek_add_numeric_attribute(igraph_trie_t *names, +static igraph_error_t add_numeric_attribute(igraph_trie_t *names, igraph_vector_ptr_t *attrs, igraph_integer_t count, const char *attrname, igraph_integer_t vid, igraph_real_t number); -static igraph_error_t igraph_i_pajek_add_string_attribute(igraph_trie_t *names, +static igraph_error_t add_string_attribute(igraph_trie_t *names, igraph_vector_ptr_t *attrs, igraph_integer_t count, const char *attrname, @@ -144,13 +144,18 @@ static igraph_error_t igraph_i_pajek_add_string_attribute(igraph_trie_t *names, const char *str, igraph_integer_t str_len); -static igraph_error_t igraph_i_pajek_add_bipartite_type(igraph_i_pajek_parsedata_t *context); -static igraph_error_t igraph_i_pajek_check_bipartite(igraph_i_pajek_parsedata_t *context); +static igraph_error_t add_bipartite_type(igraph_i_pajek_parsedata_t *context); +static igraph_error_t check_bipartite(igraph_i_pajek_parsedata_t *context); + +static igraph_error_t make_dynstr(const char *src, size_t len, char **res); +static igraph_bool_t is_standard_vattr(const char *attrname); +static igraph_bool_t is_standard_eattr(const char *attrname); +static igraph_error_t deconflict_attrname(char **attrname); #define scanner context->scanner -#line 154 "yy.tab.c" +#line 159 "yy.tab.c" # ifndef YY_CAST # ifdef __cplusplus @@ -183,119 +188,103 @@ enum yysymbol_kind_t YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ YYSYMBOL_NEWLINE = 3, /* "end of line" */ YYSYMBOL_NUM = 4, /* "number" */ - YYSYMBOL_ALNUM = 5, /* ALNUM */ - YYSYMBOL_QSTR = 6, /* QSTR */ - YYSYMBOL_PSTR = 7, /* PSTR */ - YYSYMBOL_NETWORKLINE = 8, /* "*network line" */ - YYSYMBOL_NET_TITLE = 9, /* NET_TITLE */ - YYSYMBOL_VERTICESLINE = 10, /* "*vertices line" */ - YYSYMBOL_ARCSLINE = 11, /* "*arcs line" */ - YYSYMBOL_EDGESLINE = 12, /* "*edges line" */ - YYSYMBOL_ARCSLISTLINE = 13, /* "*arcslist line" */ - YYSYMBOL_EDGESLISTLINE = 14, /* "*edgeslist line" */ - YYSYMBOL_MATRIXLINE = 15, /* "*matrix line" */ - YYSYMBOL_ERROR = 16, /* ERROR */ - YYSYMBOL_VP_X_FACT = 17, /* VP_X_FACT */ - YYSYMBOL_VP_Y_FACT = 18, /* VP_Y_FACT */ - YYSYMBOL_VP_IC = 19, /* VP_IC */ - YYSYMBOL_VP_BC = 20, /* VP_BC */ - YYSYMBOL_VP_LC = 21, /* VP_LC */ - YYSYMBOL_VP_LR = 22, /* VP_LR */ - YYSYMBOL_VP_LPHI = 23, /* VP_LPHI */ - YYSYMBOL_VP_BW = 24, /* VP_BW */ - YYSYMBOL_VP_FOS = 25, /* VP_FOS */ - YYSYMBOL_VP_PHI = 26, /* VP_PHI */ - YYSYMBOL_VP_R = 27, /* VP_R */ - YYSYMBOL_VP_Q = 28, /* VP_Q */ - YYSYMBOL_VP_LA = 29, /* VP_LA */ - YYSYMBOL_VP_FONT = 30, /* VP_FONT */ - YYSYMBOL_VP_URL = 31, /* VP_URL */ - YYSYMBOL_VP_SIZE = 32, /* VP_SIZE */ + YYSYMBOL_ALNUM = 5, /* "word" */ + YYSYMBOL_QSTR = 6, /* "quoted string" */ + YYSYMBOL_NETWORKLINE = 7, /* "*Network line" */ + YYSYMBOL_VERTICESLINE = 8, /* "*Vertices line" */ + YYSYMBOL_ARCSLINE = 9, /* "*Arcs line" */ + YYSYMBOL_EDGESLINE = 10, /* "*Edges line" */ + YYSYMBOL_ARCSLISTLINE = 11, /* "*Arcslist line" */ + YYSYMBOL_EDGESLISTLINE = 12, /* "*Edgeslist line" */ + YYSYMBOL_MATRIXLINE = 13, /* "*Matrix line" */ + YYSYMBOL_ERROR = 14, /* ERROR */ + YYSYMBOL_VP_X_FACT = 15, /* VP_X_FACT */ + YYSYMBOL_VP_Y_FACT = 16, /* VP_Y_FACT */ + YYSYMBOL_VP_PHI = 17, /* VP_PHI */ + YYSYMBOL_VP_R = 18, /* VP_R */ + YYSYMBOL_VP_Q = 19, /* VP_Q */ + YYSYMBOL_VP_IC = 20, /* VP_IC */ + YYSYMBOL_VP_BC = 21, /* VP_BC */ + YYSYMBOL_VP_BW = 22, /* VP_BW */ + YYSYMBOL_VP_LC = 23, /* VP_LC */ + YYSYMBOL_VP_LA = 24, /* VP_LA */ + YYSYMBOL_VP_LR = 25, /* VP_LR */ + YYSYMBOL_VP_LPHI = 26, /* VP_LPHI */ + YYSYMBOL_VP_FOS = 27, /* VP_FOS */ + YYSYMBOL_VP_FONT = 28, /* VP_FONT */ + YYSYMBOL_VP_URL = 29, /* VP_URL */ + YYSYMBOL_EP_H1 = 30, /* EP_H1 */ + YYSYMBOL_EP_H2 = 31, /* EP_H2 */ + YYSYMBOL_EP_W = 32, /* EP_W */ YYSYMBOL_EP_C = 33, /* EP_C */ - YYSYMBOL_EP_S = 34, /* EP_S */ + YYSYMBOL_EP_P = 34, /* EP_P */ YYSYMBOL_EP_A = 35, /* EP_A */ - YYSYMBOL_EP_W = 36, /* EP_W */ - YYSYMBOL_EP_H1 = 37, /* EP_H1 */ - YYSYMBOL_EP_H2 = 38, /* EP_H2 */ - YYSYMBOL_EP_A1 = 39, /* EP_A1 */ - YYSYMBOL_EP_A2 = 40, /* EP_A2 */ - YYSYMBOL_EP_K1 = 41, /* EP_K1 */ - YYSYMBOL_EP_K2 = 42, /* EP_K2 */ - YYSYMBOL_EP_AP = 43, /* EP_AP */ - YYSYMBOL_EP_P = 44, /* EP_P */ - YYSYMBOL_EP_L = 45, /* EP_L */ - YYSYMBOL_EP_LP = 46, /* EP_LP */ - YYSYMBOL_EP_LR = 47, /* EP_LR */ - YYSYMBOL_EP_LPHI = 48, /* EP_LPHI */ - YYSYMBOL_EP_LC = 49, /* EP_LC */ - YYSYMBOL_EP_LA = 50, /* EP_LA */ - YYSYMBOL_EP_SIZE = 51, /* EP_SIZE */ - YYSYMBOL_EP_FOS = 52, /* EP_FOS */ - YYSYMBOL_YYACCEPT = 53, /* $accept */ - YYSYMBOL_input = 54, /* input */ - YYSYMBOL_nethead = 55, /* nethead */ - YYSYMBOL_vertices = 56, /* vertices */ - YYSYMBOL_verticeshead = 57, /* verticeshead */ - YYSYMBOL_vertdefs = 58, /* vertdefs */ - YYSYMBOL_vertexline = 59, /* vertexline */ - YYSYMBOL_60_1 = 60, /* $@1 */ - YYSYMBOL_vertex = 61, /* vertex */ - YYSYMBOL_vertexid = 62, /* vertexid */ - YYSYMBOL_vertexcoords = 63, /* vertexcoords */ - YYSYMBOL_shape = 64, /* shape */ - YYSYMBOL_params = 65, /* params */ - YYSYMBOL_param = 66, /* param */ - YYSYMBOL_vpword = 67, /* vpword */ - YYSYMBOL_68_2 = 68, /* $@2 */ - YYSYMBOL_69_3 = 69, /* $@3 */ - YYSYMBOL_70_4 = 70, /* $@4 */ - YYSYMBOL_71_5 = 71, /* $@5 */ - YYSYMBOL_72_6 = 72, /* $@6 */ - YYSYMBOL_vpwordpar = 73, /* vpwordpar */ - YYSYMBOL_edgeblock = 74, /* edgeblock */ - YYSYMBOL_arcs = 75, /* arcs */ - YYSYMBOL_arcsdefs = 76, /* arcsdefs */ - YYSYMBOL_arcsline = 77, /* arcsline */ - YYSYMBOL_78_7 = 78, /* $@7 */ - YYSYMBOL_arcfrom = 79, /* arcfrom */ - YYSYMBOL_arcto = 80, /* arcto */ - YYSYMBOL_edges = 81, /* edges */ - YYSYMBOL_edgesdefs = 82, /* edgesdefs */ - YYSYMBOL_edgesline = 83, /* edgesline */ - YYSYMBOL_84_8 = 84, /* $@8 */ - YYSYMBOL_edgefrom = 85, /* edgefrom */ - YYSYMBOL_edgeto = 86, /* edgeto */ - YYSYMBOL_weight = 87, /* weight */ - YYSYMBOL_edgeparams = 88, /* edgeparams */ - YYSYMBOL_edgeparam = 89, /* edgeparam */ - YYSYMBOL_epword = 90, /* epword */ - YYSYMBOL_91_9 = 91, /* $@9 */ - YYSYMBOL_92_10 = 92, /* $@10 */ - YYSYMBOL_93_11 = 93, /* $@11 */ - YYSYMBOL_94_12 = 94, /* $@12 */ - YYSYMBOL_95_13 = 95, /* $@13 */ - YYSYMBOL_epwordpar = 96, /* epwordpar */ - YYSYMBOL_arcslist = 97, /* arcslist */ - YYSYMBOL_arcslistlines = 98, /* arcslistlines */ - YYSYMBOL_arclistline = 99, /* arclistline */ - YYSYMBOL_arctolist = 100, /* arctolist */ - YYSYMBOL_arclistfrom = 101, /* arclistfrom */ - YYSYMBOL_arclistto = 102, /* arclistto */ - YYSYMBOL_edgeslist = 103, /* edgeslist */ - YYSYMBOL_edgelistlines = 104, /* edgelistlines */ - YYSYMBOL_edgelistline = 105, /* edgelistline */ - YYSYMBOL_edgetolist = 106, /* edgetolist */ - YYSYMBOL_edgelistfrom = 107, /* edgelistfrom */ - YYSYMBOL_edgelistto = 108, /* edgelistto */ - YYSYMBOL_adjmatrix = 109, /* adjmatrix */ - YYSYMBOL_matrixline = 110, /* matrixline */ - YYSYMBOL_adjmatrixlines = 111, /* adjmatrixlines */ - YYSYMBOL_adjmatrixline = 112, /* adjmatrixline */ - YYSYMBOL_adjmatrixnumbers = 113, /* adjmatrixnumbers */ - YYSYMBOL_adjmatrixentry = 114, /* adjmatrixentry */ - YYSYMBOL_longint = 115, /* longint */ - YYSYMBOL_number = 116, /* number */ - YYSYMBOL_word = 117 /* word */ + YYSYMBOL_EP_S = 36, /* EP_S */ + YYSYMBOL_EP_A1 = 37, /* EP_A1 */ + YYSYMBOL_EP_K1 = 38, /* EP_K1 */ + YYSYMBOL_EP_A2 = 39, /* EP_A2 */ + YYSYMBOL_EP_K2 = 40, /* EP_K2 */ + YYSYMBOL_EP_AP = 41, /* EP_AP */ + YYSYMBOL_EP_L = 42, /* EP_L */ + YYSYMBOL_EP_LP = 43, /* EP_LP */ + YYSYMBOL_EP_LR = 44, /* EP_LR */ + YYSYMBOL_EP_LPHI = 45, /* EP_LPHI */ + YYSYMBOL_EP_LC = 46, /* EP_LC */ + YYSYMBOL_EP_LA = 47, /* EP_LA */ + YYSYMBOL_EP_FOS = 48, /* EP_FOS */ + YYSYMBOL_EP_FONT = 49, /* EP_FONT */ + YYSYMBOL_YYACCEPT = 50, /* $accept */ + YYSYMBOL_input = 51, /* input */ + YYSYMBOL_final_newlines = 52, /* final_newlines */ + YYSYMBOL_nethead = 53, /* nethead */ + YYSYMBOL_vertices = 54, /* vertices */ + YYSYMBOL_verticeshead = 55, /* verticeshead */ + YYSYMBOL_vertdefs = 56, /* vertdefs */ + YYSYMBOL_vertexline = 57, /* vertexline */ + YYSYMBOL_58_1 = 58, /* $@1 */ + YYSYMBOL_vertex = 59, /* vertex */ + YYSYMBOL_vertexid = 60, /* vertexid */ + YYSYMBOL_vertexcoords = 61, /* vertexcoords */ + YYSYMBOL_shape = 62, /* shape */ + YYSYMBOL_vertparams = 63, /* vertparams */ + YYSYMBOL_vertparam = 64, /* vertparam */ + YYSYMBOL_vpword = 65, /* vpword */ + YYSYMBOL_edgeblock = 66, /* edgeblock */ + YYSYMBOL_arcs = 67, /* arcs */ + YYSYMBOL_arcsdefs = 68, /* arcsdefs */ + YYSYMBOL_arcsline = 69, /* arcsline */ + YYSYMBOL_70_2 = 70, /* $@2 */ + YYSYMBOL_edges = 71, /* edges */ + YYSYMBOL_edgesdefs = 72, /* edgesdefs */ + YYSYMBOL_edgesline = 73, /* edgesline */ + YYSYMBOL_74_3 = 74, /* $@3 */ + YYSYMBOL_weight = 75, /* weight */ + YYSYMBOL_edgeparams = 76, /* edgeparams */ + YYSYMBOL_edgeparam = 77, /* edgeparam */ + YYSYMBOL_epword = 78, /* epword */ + YYSYMBOL_arcslist = 79, /* arcslist */ + YYSYMBOL_arcslistlines = 80, /* arcslistlines */ + YYSYMBOL_arclistline = 81, /* arclistline */ + YYSYMBOL_arctolist = 82, /* arctolist */ + YYSYMBOL_arclistfrom = 83, /* arclistfrom */ + YYSYMBOL_arclistto = 84, /* arclistto */ + YYSYMBOL_edgeslist = 85, /* edgeslist */ + YYSYMBOL_edgelistlines = 86, /* edgelistlines */ + YYSYMBOL_edgelistline = 87, /* edgelistline */ + YYSYMBOL_edgetolist = 88, /* edgetolist */ + YYSYMBOL_edgelistfrom = 89, /* edgelistfrom */ + YYSYMBOL_edgelistto = 90, /* edgelistto */ + YYSYMBOL_adjmatrix = 91, /* adjmatrix */ + YYSYMBOL_matrixline = 92, /* matrixline */ + YYSYMBOL_adjmatrixlines = 93, /* adjmatrixlines */ + YYSYMBOL_adjmatrixline = 94, /* adjmatrixline */ + YYSYMBOL_adjmatrixnumbers = 95, /* adjmatrixnumbers */ + YYSYMBOL_adjmatrixentry = 96, /* adjmatrixentry */ + YYSYMBOL_integer = 97, /* integer */ + YYSYMBOL_number = 98, /* number */ + YYSYMBOL_parname = 99, /* parname */ + YYSYMBOL_parstrval = 100, /* parstrval */ + YYSYMBOL_word = 101 /* word */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -624,21 +613,21 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 6 +#define YYFINAL 4 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 223 +#define YYLAST 215 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 53 +#define YYNTOKENS 50 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 65 +#define YYNNTS 52 /* YYNRULES -- Number of rules. */ -#define YYNRULES 136 +#define YYNRULES 115 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 207 +#define YYNSTATES 178 /* YYMAXUTOK -- Last valid token kind. */ -#define YYMAXUTOK 307 +#define YYMAXUTOK 304 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM @@ -682,27 +671,25 @@ static const yytype_int8 yytranslate[] = 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52 + 45, 46, 47, 48, 49 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 187, 187, 191, 191, 191, 193, 195, 205, 223, - 223, 225, 226, 227, 227, 238, 240, 245, 246, 250, - 256, 256, 260, 260, 263, 264, 267, 270, 275, 280, - 285, 288, 291, 294, 297, 300, 303, 306, 309, 314, - 314, 318, 318, 322, 322, 326, 326, 331, 331, 338, - 340, 340, 340, 340, 340, 340, 342, 343, 345, 345, - 347, 348, 348, 360, 362, 364, 365, 367, 367, 369, - 370, 370, 382, 384, 386, 386, 390, 390, 393, 394, - 399, 402, 405, 408, 411, 414, 417, 420, 423, 426, - 429, 432, 435, 438, 441, 446, 446, 450, 450, 454, - 454, 458, 458, 462, 462, 468, 470, 472, 472, 474, - 474, 476, 476, 478, 480, 485, 487, 487, 489, 489, - 491, 491, 493, 495, 502, 504, 509, 509, 511, 513, - 513, 515, 535, 543, 551, 553, 555 + 0, 188, 188, 199, 199, 201, 201, 203, 205, 215, + 233, 233, 235, 236, 236, 239, 250, 255, 256, 260, + 266, 266, 270, 270, 273, 274, 277, 280, 283, 286, + 289, 292, 295, 298, 301, 306, 309, 312, 315, 318, + 321, 336, 336, 336, 336, 336, 336, 338, 339, 341, + 341, 343, 343, 348, 349, 351, 351, 353, 353, 358, + 358, 362, 362, 365, 366, 369, 372, 375, 378, 381, + 384, 387, 390, 393, 396, 399, 402, 405, 410, 413, + 416, 419, 422, 425, 428, 443, 445, 445, 447, 449, + 449, 451, 453, 458, 460, 460, 462, 464, 464, 466, + 468, 475, 477, 482, 482, 484, 486, 486, 488, 508, + 516, 524, 528, 530, 532, 534 }; #endif @@ -719,25 +706,24 @@ static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; static const char *const yytname[] = { "\"end of file\"", "error", "\"invalid token\"", "\"end of line\"", - "\"number\"", "ALNUM", "QSTR", "PSTR", "\"*network line\"", "NET_TITLE", - "\"*vertices line\"", "\"*arcs line\"", "\"*edges line\"", - "\"*arcslist line\"", "\"*edgeslist line\"", "\"*matrix line\"", "ERROR", - "VP_X_FACT", "VP_Y_FACT", "VP_IC", "VP_BC", "VP_LC", "VP_LR", "VP_LPHI", - "VP_BW", "VP_FOS", "VP_PHI", "VP_R", "VP_Q", "VP_LA", "VP_FONT", - "VP_URL", "VP_SIZE", "EP_C", "EP_S", "EP_A", "EP_W", "EP_H1", "EP_H2", - "EP_A1", "EP_A2", "EP_K1", "EP_K2", "EP_AP", "EP_P", "EP_L", "EP_LP", - "EP_LR", "EP_LPHI", "EP_LC", "EP_LA", "EP_SIZE", "EP_FOS", "$accept", - "input", "nethead", "vertices", "verticeshead", "vertdefs", "vertexline", - "$@1", "vertex", "vertexid", "vertexcoords", "shape", "params", "param", - "vpword", "$@2", "$@3", "$@4", "$@5", "$@6", "vpwordpar", "edgeblock", - "arcs", "arcsdefs", "arcsline", "$@7", "arcfrom", "arcto", "edges", - "edgesdefs", "edgesline", "$@8", "edgefrom", "edgeto", "weight", - "edgeparams", "edgeparam", "epword", "$@9", "$@10", "$@11", "$@12", - "$@13", "epwordpar", "arcslist", "arcslistlines", "arclistline", - "arctolist", "arclistfrom", "arclistto", "edgeslist", "edgelistlines", - "edgelistline", "edgetolist", "edgelistfrom", "edgelistto", "adjmatrix", - "matrixline", "adjmatrixlines", "adjmatrixline", "adjmatrixnumbers", - "adjmatrixentry", "longint", "number", "word", YY_NULLPTR + "\"number\"", "\"word\"", "\"quoted string\"", "\"*Network line\"", + "\"*Vertices line\"", "\"*Arcs line\"", "\"*Edges line\"", + "\"*Arcslist line\"", "\"*Edgeslist line\"", "\"*Matrix line\"", "ERROR", + "VP_X_FACT", "VP_Y_FACT", "VP_PHI", "VP_R", "VP_Q", "VP_IC", "VP_BC", + "VP_BW", "VP_LC", "VP_LA", "VP_LR", "VP_LPHI", "VP_FOS", "VP_FONT", + "VP_URL", "EP_H1", "EP_H2", "EP_W", "EP_C", "EP_P", "EP_A", "EP_S", + "EP_A1", "EP_K1", "EP_A2", "EP_K2", "EP_AP", "EP_L", "EP_LP", "EP_LR", + "EP_LPHI", "EP_LC", "EP_LA", "EP_FOS", "EP_FONT", "$accept", "input", + "final_newlines", "nethead", "vertices", "verticeshead", "vertdefs", + "vertexline", "$@1", "vertex", "vertexid", "vertexcoords", "shape", + "vertparams", "vertparam", "vpword", "edgeblock", "arcs", "arcsdefs", + "arcsline", "$@2", "edges", "edgesdefs", "edgesline", "$@3", "weight", + "edgeparams", "edgeparam", "epword", "arcslist", "arcslistlines", + "arclistline", "arctolist", "arclistfrom", "arclistto", "edgeslist", + "edgelistlines", "edgelistline", "edgetolist", "edgelistfrom", + "edgelistto", "adjmatrix", "matrixline", "adjmatrixlines", + "adjmatrixline", "adjmatrixnumbers", "adjmatrixentry", "integer", + "number", "parname", "parstrval", "word", YY_NULLPTR }; static const char * @@ -747,12 +733,12 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#define YYPACT_NINF (-168) +#define YYPACT_NINF (-94) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-130) +#define YYTABLE_NINF (-1) #define yytable_value_is_error(Yyn) \ 0 @@ -761,201 +747,184 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int16 yypact[] = { - -2, 6, 4, 12, -168, 34, -168, 35, -168, 50, - -168, -168, 35, 13, -168, -168, 10, 26, 54, 56, - -168, -168, -168, -168, -168, -168, 57, 28, -168, -168, - 58, -168, 59, -168, -168, -168, -168, -168, 60, -168, - 30, -168, 32, -168, 39, 41, 45, -168, 15, -168, - -168, 35, -168, 30, -168, -168, 35, -168, 32, -168, - -168, -168, -168, -168, -168, -168, -168, -168, 61, 62, - -168, -168, -168, -168, 62, -168, -168, -168, -168, -168, - 47, 52, -168, -168, 15, 62, 62, 62, -168, -168, - -168, -168, -168, -168, -168, -168, 62, -168, -168, -168, - 139, -168, 150, 171, -168, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, -168, -168, - 62, -168, -168, -168, 62, 62, -168, 62, 62, 62, - 62, 62, 62, 62, 62, -168, -168, 62, 62, 62, - -168, 62, 62, 62, -168, -168, -168, -168, -168, 15, - 62, 15, 62, 15, 62, -168, -168, -168, -168, -168, - -168, -168, -168, 15, 15, -168, 15, 62, -168, 15, - -168, -168, -168, -168, -168, -168, -168, -168, 15, 15, - -168, -168, -168, 15, -168, -168, -168, -168, -168, 62, - -168, 62, -168, 62, -168, -168, -168, -168, 62, -168, - -168, -168, -168, -168, -168, -168, -168 + 3, -94, 21, 0, -94, 11, -94, 22, -94, 11, + 45, -94, -94, 27, 1, 15, 30, 35, -94, -94, + -94, -94, -94, -94, -94, 40, 11, -94, -94, -94, + 41, -94, 43, -94, -94, -94, -94, 48, -94, 11, + -94, 11, -94, 11, 11, 55, -94, 8, 11, -94, + 11, 11, -94, 11, -94, -94, -94, -94, -94, -94, + -94, 49, 55, -94, -94, -94, -94, 55, -94, -94, + -94, 20, 33, -94, -94, 8, 55, 55, 55, -94, + -94, -94, -94, -94, -94, -94, -94, 55, -94, -94, + -94, 186, -94, 92, 139, -94, 55, 55, 55, 55, + 55, 8, 8, 55, 8, 55, 55, 55, 55, 8, + 8, -94, -94, 8, -94, -94, 55, 55, 55, 8, + 8, 8, 55, 55, 55, 55, 55, 55, 8, 55, + 55, 55, 8, 55, 55, 8, -94, -94, 8, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ -static const yytype_uint8 yydefact[] = +static const yytype_int8 yydefact[] = { - 3, 0, 0, 0, 4, 0, 1, 0, 50, 0, - 5, 132, 7, 2, 9, 8, 0, 0, 0, 0, - 125, 51, 52, 53, 54, 55, 0, 6, 58, 133, - 0, 67, 0, 107, 116, 126, 11, 10, 13, 15, - 56, 58, 65, 67, 106, 115, 124, 12, 0, 60, - 59, 0, 63, 57, 69, 68, 0, 72, 66, 109, - 108, 111, 113, 118, 117, 120, 122, 127, 0, 129, - 131, 135, 134, 136, 17, 16, 61, 64, 70, 73, - 0, 0, 128, 130, 20, 0, 74, 74, 110, 112, - 114, 119, 121, 123, 22, 21, 18, 76, 75, 76, - 0, 19, 0, 0, 14, 0, 0, 43, 45, 47, - 0, 0, 0, 0, 0, 0, 0, 0, 39, 41, - 0, 23, 24, 62, 103, 0, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 97, 99, 0, 0, 0, - 101, 0, 0, 0, 77, 78, 71, 25, 26, 0, - 0, 0, 0, 0, 0, 30, 31, 32, 33, 34, - 35, 36, 37, 0, 0, 38, 0, 0, 80, 0, - 81, 82, 83, 84, 85, 86, 87, 88, 0, 0, - 89, 90, 91, 0, 92, 93, 94, 44, 49, 0, - 46, 0, 48, 0, 40, 42, 104, 105, 0, 96, - 98, 100, 102, 27, 28, 29, 79 + 5, 6, 0, 0, 1, 0, 41, 0, 109, 8, + 3, 10, 9, 3, 0, 0, 0, 0, 102, 2, + 42, 43, 44, 45, 46, 0, 7, 4, 49, 110, + 0, 55, 0, 86, 94, 103, 11, 13, 15, 47, + 49, 53, 55, 85, 93, 101, 12, 0, 0, 50, + 48, 0, 56, 54, 87, 89, 91, 95, 97, 99, + 104, 0, 106, 108, 114, 113, 115, 17, 16, 51, + 57, 0, 0, 105, 107, 20, 0, 59, 59, 88, + 90, 92, 96, 98, 100, 22, 21, 18, 61, 60, + 61, 0, 19, 0, 0, 14, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 23, 24, 0, 111, 52, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 62, 63, 0, 58, + 25, 26, 31, 32, 33, 37, 112, 38, 29, 39, + 34, 27, 28, 30, 35, 36, 40, 66, 67, 65, + 82, 79, 78, 64, 68, 70, 69, 71, 72, 80, + 73, 74, 75, 81, 76, 77, 83, 84 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = +static const yytype_int8 yypgoto[] = { - -168, -168, -168, -168, -168, -168, -168, -168, -168, -168, - -168, -168, -168, -168, -168, -168, -168, -168, -168, -168, - -146, -168, -168, 24, -168, -168, -168, -168, -168, 25, - -168, -168, -168, -168, -20, -27, -168, -168, -168, -168, - -168, -168, -168, -167, -168, -168, -168, -168, -168, -168, - -168, -168, -168, -168, -168, -168, -168, -168, -168, -168, - 5, -168, -4, -16, -38 + -94, -94, 47, -94, -94, -94, -94, -94, -94, -19, + -94, -94, -94, -94, -94, -94, -94, -94, 25, -94, + -94, -94, 19, -94, -94, -12, -23, -94, -94, -94, + -94, -94, -94, -94, -94, -94, -94, -94, -94, -94, + -94, -94, -94, -94, -94, 9, -94, -3, -14, -21, + -93, -44 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_uint8 yydefgoto[] = { - 0, 2, 3, 8, 9, 27, 37, 48, 38, 74, - 84, 94, 100, 121, 122, 163, 164, 149, 151, 153, - 187, 13, 21, 40, 50, 86, 51, 76, 22, 42, - 55, 87, 56, 78, 97, 102, 144, 145, 169, 178, - 179, 183, 166, 196, 23, 44, 60, 80, 61, 89, - 24, 45, 64, 81, 65, 92, 25, 26, 46, 67, - 68, 69, 52, 70, 188 + 0, 2, 19, 3, 6, 7, 26, 36, 47, 48, + 67, 75, 85, 91, 111, 112, 10, 20, 39, 49, + 77, 21, 41, 52, 78, 88, 93, 136, 137, 22, + 43, 54, 71, 55, 80, 23, 44, 57, 72, 58, + 83, 24, 25, 45, 60, 61, 62, 38, 63, 138, + 145, 146 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int16 yytable[] = +static const yytype_uint8 yytable[] = { - 30, 32, 199, 12, 6, 190, 1, 192, 15, 4, - 75, 200, 201, 28, 29, 5, 202, 194, 195, 71, - 72, 73, 7, 39, 16, 17, 18, 19, 20, 31, - 29, 36, 11, 49, 11, 54, 11, 10, 57, 11, - 62, 66, 59, 11, 63, 11, 95, 77, -129, 29, - 88, 11, 79, 14, 57, 91, 11, 33, 85, 34, - 35, 41, 43, 47, 82, 53, 29, 99, 58, 96, - 98, 98, 103, 0, 83, 0, 90, 93, 0, 0, - 101, 0, 0, 0, 0, 0, 0, 0, 0, 147, - 148, 150, 152, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 0, 0, 165, 0, 0, 0, 167, 168, - 0, 170, 171, 172, 173, 174, 175, 176, 177, 0, - 0, 180, 181, 182, 0, 184, 185, 186, 197, 0, - 0, 197, 0, 0, 189, 0, 191, 0, 193, 0, - 197, 197, 104, 0, 0, 197, 0, 0, 0, 0, - 0, 198, 0, 123, 0, 0, 105, 106, 107, 108, - 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, 0, 203, 146, 204, 0, 205, 0, 0, - 0, 0, 206, 124, 125, 126, 127, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 0, 124, 125, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143 + 30, 32, 9, 68, 28, 29, 12, 37, 5, 147, + 1, 149, 64, 65, 66, 8, 154, 155, 31, 29, + 156, 4, 51, 79, 8, 11, 160, 161, 162, 69, + 13, 86, 70, 33, 51, 169, 82, 8, 34, 173, + 56, 59, 176, 35, 40, 177, 42, 114, 13, 114, + 114, 46, 73, 76, 14, 15, 16, 17, 18, 29, + 27, 53, 87, 89, 89, 50, 90, 94, 81, 84, + 113, 74, 0, 92, 0, 0, 0, 0, 0, 0, + 0, 0, 140, 141, 142, 143, 144, 0, 0, 148, + 0, 150, 151, 152, 153, 115, 64, 65, 66, 0, + 0, 0, 157, 158, 159, 0, 0, 0, 163, 164, + 165, 166, 167, 168, 0, 170, 171, 172, 0, 174, + 175, 0, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 139, 64, 65, 66, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 95, + 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, + 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110 }; static const yytype_int16 yycheck[] = { - 16, 17, 169, 7, 0, 151, 8, 153, 12, 3, - 48, 178, 179, 3, 4, 9, 183, 163, 164, 4, - 5, 6, 10, 27, 11, 12, 13, 14, 15, 3, - 4, 3, 4, 3, 4, 3, 4, 3, 42, 4, - 44, 45, 3, 4, 3, 4, 84, 51, 3, 4, - 3, 4, 56, 3, 58, 3, 4, 3, 74, 3, - 3, 3, 3, 3, 3, 41, 4, 87, 43, 85, - 86, 87, 99, -1, 69, -1, 80, 81, -1, -1, - 96, -1, -1, -1, -1, -1, -1, -1, -1, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, -1, -1, 120, -1, -1, -1, 124, 125, - -1, 127, 128, 129, 130, 131, 132, 133, 134, -1, - -1, 137, 138, 139, -1, 141, 142, 143, 166, -1, - -1, 169, -1, -1, 150, -1, 152, -1, 154, -1, - 178, 179, 3, -1, -1, 183, -1, -1, -1, -1, - -1, 167, -1, 3, -1, -1, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, -1, 189, 3, 191, -1, 193, -1, -1, - -1, -1, 198, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, -1, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52 + 14, 15, 5, 47, 3, 4, 9, 26, 8, 102, + 7, 104, 4, 5, 6, 4, 109, 110, 3, 4, + 113, 0, 41, 3, 4, 3, 119, 120, 121, 48, + 3, 75, 51, 3, 53, 128, 3, 4, 3, 132, + 43, 44, 135, 3, 3, 138, 3, 91, 3, 93, + 94, 3, 3, 67, 9, 10, 11, 12, 13, 4, + 13, 42, 76, 77, 78, 40, 78, 90, 71, 72, + 91, 62, -1, 87, -1, -1, -1, -1, -1, -1, + -1, -1, 96, 97, 98, 99, 100, -1, -1, 103, + -1, 105, 106, 107, 108, 3, 4, 5, 6, -1, + -1, -1, 116, 117, 118, -1, -1, -1, 122, 123, + 124, 125, 126, 127, -1, 129, 130, 131, -1, 133, + 134, -1, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 3, 4, 5, 6, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 3, + 4, 5, 6, -1, -1, -1, -1, -1, -1, -1, + -1, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { - 0, 8, 54, 55, 3, 9, 0, 10, 56, 57, - 3, 4, 115, 74, 3, 115, 11, 12, 13, 14, - 15, 75, 81, 97, 103, 109, 110, 58, 3, 4, - 116, 3, 116, 3, 3, 3, 3, 59, 61, 115, - 76, 3, 82, 3, 98, 104, 111, 3, 60, 3, - 77, 79, 115, 76, 3, 83, 85, 115, 82, 3, - 99, 101, 115, 3, 105, 107, 115, 112, 113, 114, - 116, 4, 5, 6, 62, 117, 80, 115, 86, 115, - 100, 106, 3, 113, 63, 116, 78, 84, 3, 102, - 115, 3, 108, 115, 64, 117, 116, 87, 116, 87, - 65, 116, 88, 88, 3, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 66, 67, 3, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 89, 90, 3, 116, 116, 70, - 116, 71, 116, 72, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 68, 69, 116, 95, 116, 116, 91, - 116, 116, 116, 116, 116, 116, 116, 116, 92, 93, - 116, 116, 116, 94, 116, 116, 116, 73, 117, 116, - 73, 116, 73, 116, 73, 73, 96, 117, 116, 96, - 96, 96, 96, 116, 116, 116, 116 + 0, 7, 51, 53, 0, 8, 54, 55, 4, 97, + 66, 3, 97, 3, 9, 10, 11, 12, 13, 52, + 67, 71, 79, 85, 91, 92, 56, 52, 3, 4, + 98, 3, 98, 3, 3, 3, 57, 59, 97, 68, + 3, 72, 3, 80, 86, 93, 3, 58, 59, 69, + 68, 59, 73, 72, 81, 83, 97, 87, 89, 97, + 94, 95, 96, 98, 4, 5, 6, 60, 101, 59, + 59, 82, 88, 3, 95, 61, 98, 70, 74, 3, + 84, 97, 3, 90, 97, 62, 101, 98, 75, 98, + 75, 63, 98, 76, 76, 3, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 64, 65, 99, 101, 3, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 77, 78, 99, 3, + 98, 98, 98, 98, 98, 100, 101, 100, 98, 100, + 98, 98, 98, 98, 100, 100, 100, 98, 98, 98, + 100, 100, 100, 98, 98, 98, 98, 98, 98, 100, + 98, 98, 98, 100, 98, 98, 100, 100 }; /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ static const yytype_int8 yyr1[] = { - 0, 53, 54, 55, 55, 55, 56, 57, 57, 58, - 58, 59, 59, 60, 59, 61, 62, 63, 63, 63, - 64, 64, 65, 65, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 68, - 67, 69, 67, 70, 67, 71, 67, 72, 67, 73, - 74, 74, 74, 74, 74, 74, 75, 75, 76, 76, - 77, 78, 77, 79, 80, 81, 81, 82, 82, 83, - 84, 83, 85, 86, 87, 87, 88, 88, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 91, 90, 92, 90, 93, - 90, 94, 90, 95, 90, 96, 97, 98, 98, 99, - 99, 100, 100, 101, 102, 103, 104, 104, 105, 105, - 106, 106, 107, 108, 109, 110, 111, 111, 112, 113, - 113, 114, 115, 116, 117, 117, 117 + 0, 50, 51, 52, 52, 53, 53, 54, 55, 55, + 56, 56, 57, 58, 57, 59, 60, 61, 61, 61, + 62, 62, 63, 63, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, + 65, 66, 66, 66, 66, 66, 66, 67, 67, 68, + 68, 70, 69, 71, 71, 72, 72, 74, 73, 75, + 75, 76, 76, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 78, 78, + 78, 78, 78, 78, 78, 79, 80, 80, 81, 82, + 82, 83, 84, 85, 86, 86, 87, 88, 88, 89, + 90, 91, 92, 93, 93, 94, 95, 95, 96, 97, + 98, 99, 100, 101, 101, 101 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ static const yytype_int8 yyr2[] = { - 0, 2, 3, 0, 2, 3, 3, 2, 3, 0, - 2, 1, 2, 0, 7, 1, 1, 0, 2, 3, - 0, 1, 0, 2, 1, 2, 2, 4, 4, 4, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, - 3, 0, 3, 0, 3, 0, 3, 0, 3, 1, - 0, 2, 2, 2, 2, 2, 3, 4, 0, 2, - 1, 0, 6, 1, 1, 3, 4, 0, 2, 1, - 0, 6, 1, 1, 0, 1, 0, 2, 1, 4, + 0, 2, 4, 0, 2, 0, 1, 3, 2, 3, + 0, 2, 2, 0, 7, 1, 1, 0, 2, 3, + 0, 1, 0, 2, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 0, 2, 2, 2, 2, 2, 3, 4, 0, + 2, 0, 6, 3, 4, 0, 2, 0, 6, 0, + 1, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 0, 3, 0, 3, 0, - 3, 0, 3, 0, 3, 1, 3, 0, 2, 1, - 3, 0, 2, 1, 1, 3, 0, 2, 1, 3, - 0, 2, 1, 1, 3, 1, 0, 2, 2, 0, - 2, 1, 1, 1, 1, 1, 1 + 2, 2, 2, 2, 2, 3, 0, 2, 3, 0, + 2, 1, 1, 3, 0, 2, 3, 0, 2, 1, + 1, 3, 1, 0, 2, 2, 0, 2, 1, 1, + 1, 1, 1, 1, 1, 1 }; @@ -1514,7 +1483,17 @@ yydestruct (const char *yymsg, YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); + switch (yykind) + { + case YYSYMBOL_parname: /* parname */ +#line 133 "src/vendor/cigraph/src/io/pajek-parser.y" + { free(((*yyvaluep).dynstr)); } +#line 1492 "yy.tab.c" + break; + + default: + break; + } YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1812,16 +1791,23 @@ YYLTYPE yylloc = yyloc_default; YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: /* input: nethead vertices edgeblock */ -#line 187 "src/vendor/cigraph/src/io/pajek-parser.y" - { - if (context->vcount2 > 0) { igraph_i_pajek_check_bipartite(context); } + case 2: /* input: nethead vertices edgeblock final_newlines */ +#line 188 "src/vendor/cigraph/src/io/pajek-parser.y" + { + if (context->vcount2 > 0) { check_bipartite(context); } + if (! context->eof) { + /* In Pajek files, an empty line after *Vertices signifies the end of the network data. + * If there is more data after one or more empty lines, we warn the user, as this + * may indicate file corruption, for example a stray empty lines before *Edges. */ + IGRAPH_WARNINGF("Empty line encountered, ignoring rest of file after line %d.", (yylsp[0]).first_line); + } + YYACCEPT; /* stop parsing even if there is more data in the file. */ } -#line 1821 "yy.tab.c" +#line 1807 "yy.tab.c" break; - case 7: /* verticeshead: "*vertices line" longint */ -#line 195 "src/vendor/cigraph/src/io/pajek-parser.y" + case 8: /* verticeshead: "*Vertices line" integer */ +#line 205 "src/vendor/cigraph/src/io/pajek-parser.y" { context->vcount=(yyvsp[0].intnum); context->vcount2=0; @@ -1832,11 +1818,11 @@ YYLTYPE yylloc = yyloc_default; IGRAPH_YY_ERRORF("Vertex count too large in Pajek file (%" IGRAPH_PRId ").", IGRAPH_EINVAL, context->vcount); } } -#line 1836 "yy.tab.c" +#line 1822 "yy.tab.c" break; - case 8: /* verticeshead: "*vertices line" longint longint */ -#line 205 "src/vendor/cigraph/src/io/pajek-parser.y" + case 9: /* verticeshead: "*Vertices line" integer integer */ +#line 215 "src/vendor/cigraph/src/io/pajek-parser.y" { context->vcount=(yyvsp[-1].intnum); context->vcount2=(yyvsp[0].intnum); @@ -1852,628 +1838,519 @@ YYLTYPE yylloc = yyloc_default; if (context->vcount2 > IGRAPH_PAJEK_MAX_VERTEX_COUNT) { IGRAPH_YY_ERRORF("2-mode vertex count too large in Pajek file (%" IGRAPH_PRId ").", IGRAPH_EINVAL, context->vcount2); } - IGRAPH_YY_CHECK(igraph_i_pajek_add_bipartite_type(context)); + IGRAPH_YY_CHECK(add_bipartite_type(context)); } -#line 1858 "yy.tab.c" +#line 1844 "yy.tab.c" break; case 13: /* $@1: %empty */ -#line 227 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->actvertex=(yyvsp[0].intnum); - if (context->actvertex < 1 || context->actvertex > context->vcount) { - IGRAPH_YY_ERRORF( - "Invalid vertex id (%" IGRAPH_PRId ") in Pajek file. " - "The number of vertices is %" IGRAPH_PRId ".", - IGRAPH_EINVAL, context->actvertex, context->vcount); - } - } -#line 1872 "yy.tab.c" - break; - - case 14: /* vertexline: vertex $@1 vertexid vertexcoords shape params "end of line" */ -#line 235 "src/vendor/cigraph/src/io/pajek-parser.y" - { } -#line 1878 "yy.tab.c" - break; - - case 15: /* vertex: longint */ -#line 238 "src/vendor/cigraph/src/io/pajek-parser.y" - { (yyval.intnum)=(yyvsp[0].intnum); context->mode=1; } -#line 1884 "yy.tab.c" +#line 236 "src/vendor/cigraph/src/io/pajek-parser.y" + { context->actvertex=(yyvsp[0].intnum); } +#line 1850 "yy.tab.c" + break; + + case 14: /* vertexline: vertex $@1 vertexid vertexcoords shape vertparams "end of line" */ +#line 236 "src/vendor/cigraph/src/io/pajek-parser.y" + { } +#line 1856 "yy.tab.c" + break; + + case 15: /* vertex: integer */ +#line 239 "src/vendor/cigraph/src/io/pajek-parser.y" + { + igraph_integer_t v = (yyvsp[0].intnum); + if (v < 1 || v > context->vcount) { + IGRAPH_YY_ERRORF( + "Invalid vertex id (%" IGRAPH_PRId ") in Pajek file. " + "The number of vertices is %" IGRAPH_PRId ".", + IGRAPH_EINVAL, v, context->vcount); + } + (yyval.intnum) = v; +} +#line 1871 "yy.tab.c" break; case 16: /* vertexid: word */ -#line 240 "src/vendor/cigraph/src/io/pajek-parser.y" +#line 250 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("id", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("name", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + IGRAPH_YY_CHECK(add_string_vertex_attribute("id", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + IGRAPH_YY_CHECK(add_string_vertex_attribute("name", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 1893 "yy.tab.c" +#line 1880 "yy.tab.c" break; case 18: /* vertexcoords: number number */ -#line 246 "src/vendor/cigraph/src/io/pajek-parser.y" +#line 256 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("x", (yyvsp[-1].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("y", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("x", (yyvsp[-1].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("y", (yyvsp[0].realnum), context)); } -#line 1902 "yy.tab.c" +#line 1889 "yy.tab.c" break; case 19: /* vertexcoords: number number number */ -#line 250 "src/vendor/cigraph/src/io/pajek-parser.y" +#line 260 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("x", (yyvsp[-2].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("y", (yyvsp[-1].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("z", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("x", (yyvsp[-2].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("y", (yyvsp[-1].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("z", (yyvsp[0].realnum), context)); } -#line 1912 "yy.tab.c" +#line 1899 "yy.tab.c" break; case 21: /* shape: word */ -#line 256 "src/vendor/cigraph/src/io/pajek-parser.y" +#line 266 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("shape", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + IGRAPH_YY_CHECK(add_string_vertex_attribute("shape", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 1920 "yy.tab.c" +#line 1907 "yy.tab.c" break; - case 25: /* param: VP_X_FACT number */ -#line 264 "src/vendor/cigraph/src/io/pajek-parser.y" + case 25: /* vertparam: VP_X_FACT number */ +#line 274 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("xfact", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("xfact", (yyvsp[0].realnum), context)); } -#line 1928 "yy.tab.c" +#line 1915 "yy.tab.c" break; - case 26: /* param: VP_Y_FACT number */ -#line 267 "src/vendor/cigraph/src/io/pajek-parser.y" + case 26: /* vertparam: VP_Y_FACT number */ +#line 277 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("yfact", (yyvsp[0].realnum), context)); - } -#line 1936 "yy.tab.c" - break; - - case 27: /* param: VP_IC number number number */ -#line 270 "src/vendor/cigraph/src/io/pajek-parser.y" - { /* RGB color */ - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("color-red", (yyvsp[-2].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("color-green", (yyvsp[-1].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("color-blue", (yyvsp[0].realnum), context)); - } -#line 1946 "yy.tab.c" - break; - - case 28: /* param: VP_BC number number number */ -#line 275 "src/vendor/cigraph/src/io/pajek-parser.y" - { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("framecolor-red", (yyvsp[-2].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("framecolor-green", (yyvsp[-1].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("framecolor-blue", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("yfact", (yyvsp[0].realnum), context)); } -#line 1956 "yy.tab.c" +#line 1923 "yy.tab.c" break; - case 29: /* param: VP_LC number number number */ + case 27: /* vertparam: VP_LR number */ #line 280 "src/vendor/cigraph/src/io/pajek-parser.y" - { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("labelcolor-red", (yyvsp[-2].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("labelcolor-green", (yyvsp[-1].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("labelcolor-blue", (yyvsp[0].realnum), context)); - } -#line 1966 "yy.tab.c" - break; - - case 30: /* param: VP_LR number */ -#line 285 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("labeldist", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("labeldist", (yyvsp[0].realnum), context)); } -#line 1974 "yy.tab.c" +#line 1931 "yy.tab.c" break; - case 31: /* param: VP_LPHI number */ -#line 288 "src/vendor/cigraph/src/io/pajek-parser.y" + case 28: /* vertparam: VP_LPHI number */ +#line 283 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("labeldegree2", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("labeldegree2", (yyvsp[0].realnum), context)); } -#line 1982 "yy.tab.c" +#line 1939 "yy.tab.c" break; - case 32: /* param: VP_BW number */ -#line 291 "src/vendor/cigraph/src/io/pajek-parser.y" + case 29: /* vertparam: VP_BW number */ +#line 286 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("framewidth", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("framewidth", (yyvsp[0].realnum), context)); } -#line 1990 "yy.tab.c" +#line 1947 "yy.tab.c" break; - case 33: /* param: VP_FOS number */ -#line 294 "src/vendor/cigraph/src/io/pajek-parser.y" + case 30: /* vertparam: VP_FOS number */ +#line 289 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("fontsize", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("fontsize", (yyvsp[0].realnum), context)); } -#line 1998 "yy.tab.c" +#line 1955 "yy.tab.c" break; - case 34: /* param: VP_PHI number */ -#line 297 "src/vendor/cigraph/src/io/pajek-parser.y" + case 31: /* vertparam: VP_PHI number */ +#line 292 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("rotation", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("rotation", (yyvsp[0].realnum), context)); } -#line 2006 "yy.tab.c" +#line 1963 "yy.tab.c" break; - case 35: /* param: VP_R number */ -#line 300 "src/vendor/cigraph/src/io/pajek-parser.y" + case 32: /* vertparam: VP_R number */ +#line 295 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("radius", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("radius", (yyvsp[0].realnum), context)); } -#line 2014 "yy.tab.c" +#line 1971 "yy.tab.c" break; - case 36: /* param: VP_Q number */ -#line 303 "src/vendor/cigraph/src/io/pajek-parser.y" + case 33: /* vertparam: VP_Q number */ +#line 298 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("diamondratio", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("diamondratio", (yyvsp[0].realnum), context)); } -#line 2022 "yy.tab.c" +#line 1979 "yy.tab.c" break; - case 37: /* param: VP_LA number */ -#line 306 "src/vendor/cigraph/src/io/pajek-parser.y" + case 34: /* vertparam: VP_LA number */ +#line 301 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("labeldegree", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_vertex_attribute("labeldegree", (yyvsp[0].realnum), context)); } -#line 2030 "yy.tab.c" +#line 1987 "yy.tab.c" break; - case 38: /* param: VP_SIZE number */ -#line 309 "src/vendor/cigraph/src/io/pajek-parser.y" - { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_vertex_attribute("vertexsize", (yyvsp[0].realnum), context)); + case 35: /* vpword: VP_FONT parstrval */ +#line 306 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_vertex_attribute("font", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2038 "yy.tab.c" +#line 1995 "yy.tab.c" break; - case 39: /* $@2: %empty */ -#line 314 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=3; } -#line 2044 "yy.tab.c" - break; - - case 40: /* vpword: VP_FONT $@2 vpwordpar */ -#line 314 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=1; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("font", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 36: /* vpword: VP_URL parstrval */ +#line 309 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_vertex_attribute("url", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2053 "yy.tab.c" +#line 2003 "yy.tab.c" break; - case 41: /* $@3: %empty */ -#line 318 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=3; } -#line 2059 "yy.tab.c" - break; - - case 42: /* vpword: VP_URL $@3 vpwordpar */ -#line 318 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=1; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("url", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 37: /* vpword: VP_IC parstrval */ +#line 312 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_vertex_attribute("color", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2068 "yy.tab.c" - break; - - case 43: /* $@4: %empty */ -#line 322 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=3; } -#line 2074 "yy.tab.c" +#line 2011 "yy.tab.c" break; - case 44: /* vpword: VP_IC $@4 vpwordpar */ -#line 322 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=1; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("color", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 38: /* vpword: VP_BC parstrval */ +#line 315 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_vertex_attribute("framecolor", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2083 "yy.tab.c" - break; - - case 45: /* $@5: %empty */ -#line 326 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=3; } -#line 2089 "yy.tab.c" +#line 2019 "yy.tab.c" break; - case 46: /* vpword: VP_BC $@5 vpwordpar */ -#line 326 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=1; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("framecolor", - (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 39: /* vpword: VP_LC parstrval */ +#line 318 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_vertex_attribute("labelcolor", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2099 "yy.tab.c" - break; - - case 47: /* $@6: %empty */ -#line 331 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=3; } -#line 2105 "yy.tab.c" - break; - - case 48: /* vpword: VP_LC $@6 vpwordpar */ -#line 331 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=1; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_vertex_attribute("labelcolor", - (yyvsp[0].string).str, (yyvsp[0].string).len, context)); +#line 2027 "yy.tab.c" + break; + + case 40: /* vpword: parname parstrval */ +#line 321 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_FINALLY(igraph_free, (yyvsp[-1].dynstr)); + if (is_standard_vattr((yyvsp[-1].dynstr))) { + IGRAPH_YY_CHECK(deconflict_attrname(&(yyvsp[-1].dynstr))); + /* update address on finally stack */ + IGRAPH_FINALLY_CLEAN(1); + IGRAPH_FINALLY(igraph_free, (yyvsp[-1].dynstr)); + } + IGRAPH_YY_CHECK(add_string_vertex_attribute( + (yyvsp[-1].dynstr), (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + IGRAPH_FREE((yyvsp[-1].dynstr)); + IGRAPH_FINALLY_CLEAN(1); } -#line 2115 "yy.tab.c" +#line 2045 "yy.tab.c" break; - case 49: /* vpwordpar: word */ + case 47: /* arcs: "*Arcs line" "end of line" arcsdefs */ #line 338 "src/vendor/cigraph/src/io/pajek-parser.y" - { (yyval.string)=(yyvsp[0].string); } -#line 2121 "yy.tab.c" + { context->directed=true; } +#line 2051 "yy.tab.c" break; - case 56: /* arcs: "*arcs line" "end of line" arcsdefs */ -#line 342 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->directed=1; } -#line 2127 "yy.tab.c" + case 48: /* arcs: "*Arcs line" number "end of line" arcsdefs */ +#line 339 "src/vendor/cigraph/src/io/pajek-parser.y" + { context->directed=true; } +#line 2057 "yy.tab.c" break; - case 57: /* arcs: "*arcs line" number "end of line" arcsdefs */ + case 51: /* $@2: %empty */ #line 343 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->directed=1; } -#line 2133 "yy.tab.c" - break; - - case 61: /* $@7: %empty */ -#line 348 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->actedge++; - context->mode=2; } -#line 2140 "yy.tab.c" + { context->actedge++; } +#line 2063 "yy.tab.c" break; - case 62: /* arcsline: arcfrom arcto $@7 weight edgeparams "end of line" */ -#line 349 "src/vendor/cigraph/src/io/pajek-parser.y" - { - if ((yyvsp[-5].intnum) < 1) { - IGRAPH_YY_ERRORF("Non-positive vertex ID (%" IGRAPH_PRId ") while reading Pajek file.", IGRAPH_EINVAL, (yyvsp[-5].intnum)); - } - if ((yyvsp[-4].intnum) < 1) { - IGRAPH_YY_ERRORF("Non-positive vertex ID (%" IGRAPH_PRId ") while reading Pajek file.", IGRAPH_EINVAL, (yyvsp[-4].intnum)); - } + case 52: /* arcsline: vertex vertex $@2 weight edgeparams "end of line" */ +#line 343 "src/vendor/cigraph/src/io/pajek-parser.y" + { IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-5].intnum)-1)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-4].intnum)-1)); } -#line 2154 "yy.tab.c" +#line 2071 "yy.tab.c" break; - case 65: /* edges: "*edges line" "end of line" edgesdefs */ -#line 364 "src/vendor/cigraph/src/io/pajek-parser.y" + case 53: /* edges: "*Edges line" "end of line" edgesdefs */ +#line 348 "src/vendor/cigraph/src/io/pajek-parser.y" { context->directed=0; } -#line 2160 "yy.tab.c" +#line 2077 "yy.tab.c" break; - case 66: /* edges: "*edges line" number "end of line" edgesdefs */ -#line 365 "src/vendor/cigraph/src/io/pajek-parser.y" + case 54: /* edges: "*Edges line" number "end of line" edgesdefs */ +#line 349 "src/vendor/cigraph/src/io/pajek-parser.y" { context->directed=0; } -#line 2166 "yy.tab.c" +#line 2083 "yy.tab.c" break; - case 70: /* $@8: %empty */ -#line 370 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->actedge++; - context->mode=2; } -#line 2173 "yy.tab.c" + case 57: /* $@3: %empty */ +#line 353 "src/vendor/cigraph/src/io/pajek-parser.y" + { context->actedge++; } +#line 2089 "yy.tab.c" break; - case 71: /* edgesline: edgefrom edgeto $@8 weight edgeparams "end of line" */ -#line 371 "src/vendor/cigraph/src/io/pajek-parser.y" - { - if ((yyvsp[-5].intnum) < 1) { - IGRAPH_YY_ERRORF("Non-positive vertex ID (%" IGRAPH_PRId ") while reading Pajek file.", IGRAPH_EINVAL, (yyvsp[-5].intnum)); - } - if ((yyvsp[-4].intnum) < 1) { - IGRAPH_YY_ERRORF("Non-positive vertex ID (%" IGRAPH_PRId ") while reading Pajek file.", IGRAPH_EINVAL, (yyvsp[-4].intnum)); - } + case 58: /* edgesline: vertex vertex $@3 weight edgeparams "end of line" */ +#line 353 "src/vendor/cigraph/src/io/pajek-parser.y" + { IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-5].intnum)-1)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, (yyvsp[-4].intnum)-1)); } -#line 2187 "yy.tab.c" +#line 2097 "yy.tab.c" break; - case 75: /* weight: number */ -#line 386 "src/vendor/cigraph/src/io/pajek-parser.y" + case 60: /* weight: number */ +#line 358 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("weight", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("weight", (yyvsp[0].realnum), context)); } -#line 2195 "yy.tab.c" - break; - - case 79: /* edgeparam: EP_C number number number */ -#line 394 "src/vendor/cigraph/src/io/pajek-parser.y" - { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("color-red", (yyvsp[-2].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("color-green", (yyvsp[-1].realnum), context)); - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("color-blue", (yyvsp[0].realnum), context)); - } -#line 2205 "yy.tab.c" +#line 2105 "yy.tab.c" break; - case 80: /* edgeparam: EP_S number */ -#line 399 "src/vendor/cigraph/src/io/pajek-parser.y" + case 64: /* edgeparam: EP_S number */ +#line 366 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("arrowsize", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("arrowsize", (yyvsp[0].realnum), context)); } -#line 2213 "yy.tab.c" +#line 2113 "yy.tab.c" break; - case 81: /* edgeparam: EP_W number */ -#line 402 "src/vendor/cigraph/src/io/pajek-parser.y" + case 65: /* edgeparam: EP_W number */ +#line 369 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("edgewidth", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("edgewidth", (yyvsp[0].realnum), context)); } -#line 2221 "yy.tab.c" +#line 2121 "yy.tab.c" break; - case 82: /* edgeparam: EP_H1 number */ -#line 405 "src/vendor/cigraph/src/io/pajek-parser.y" + case 66: /* edgeparam: EP_H1 number */ +#line 372 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("hook1", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("hook1", (yyvsp[0].realnum), context)); } -#line 2229 "yy.tab.c" +#line 2129 "yy.tab.c" break; - case 83: /* edgeparam: EP_H2 number */ -#line 408 "src/vendor/cigraph/src/io/pajek-parser.y" + case 67: /* edgeparam: EP_H2 number */ +#line 375 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("hook2", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("hook2", (yyvsp[0].realnum), context)); } -#line 2237 "yy.tab.c" +#line 2137 "yy.tab.c" break; - case 84: /* edgeparam: EP_A1 number */ -#line 411 "src/vendor/cigraph/src/io/pajek-parser.y" + case 68: /* edgeparam: EP_A1 number */ +#line 378 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("angle1", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("angle1", (yyvsp[0].realnum), context)); } -#line 2245 "yy.tab.c" +#line 2145 "yy.tab.c" break; - case 85: /* edgeparam: EP_A2 number */ -#line 414 "src/vendor/cigraph/src/io/pajek-parser.y" + case 69: /* edgeparam: EP_A2 number */ +#line 381 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("angle2", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("angle2", (yyvsp[0].realnum), context)); } -#line 2253 "yy.tab.c" +#line 2153 "yy.tab.c" break; - case 86: /* edgeparam: EP_K1 number */ -#line 417 "src/vendor/cigraph/src/io/pajek-parser.y" + case 70: /* edgeparam: EP_K1 number */ +#line 384 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("velocity1", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("velocity1", (yyvsp[0].realnum), context)); } -#line 2261 "yy.tab.c" +#line 2161 "yy.tab.c" break; - case 87: /* edgeparam: EP_K2 number */ -#line 420 "src/vendor/cigraph/src/io/pajek-parser.y" + case 71: /* edgeparam: EP_K2 number */ +#line 387 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("velocity2", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("velocity2", (yyvsp[0].realnum), context)); } -#line 2269 "yy.tab.c" +#line 2169 "yy.tab.c" break; - case 88: /* edgeparam: EP_AP number */ -#line 423 "src/vendor/cigraph/src/io/pajek-parser.y" + case 72: /* edgeparam: EP_AP number */ +#line 390 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("arrowpos", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("arrowpos", (yyvsp[0].realnum), context)); } -#line 2277 "yy.tab.c" +#line 2177 "yy.tab.c" break; - case 89: /* edgeparam: EP_LP number */ -#line 426 "src/vendor/cigraph/src/io/pajek-parser.y" + case 73: /* edgeparam: EP_LP number */ +#line 393 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("labelpos", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("labelpos", (yyvsp[0].realnum), context)); } -#line 2285 "yy.tab.c" +#line 2185 "yy.tab.c" break; - case 90: /* edgeparam: EP_LR number */ -#line 429 "src/vendor/cigraph/src/io/pajek-parser.y" + case 74: /* edgeparam: EP_LR number */ +#line 396 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("labelangle", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("labelangle", (yyvsp[0].realnum), context)); } -#line 2293 "yy.tab.c" +#line 2193 "yy.tab.c" break; - case 91: /* edgeparam: EP_LPHI number */ -#line 432 "src/vendor/cigraph/src/io/pajek-parser.y" + case 75: /* edgeparam: EP_LPHI number */ +#line 399 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("labelangle2", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("labelangle2", (yyvsp[0].realnum), context)); } -#line 2301 "yy.tab.c" +#line 2201 "yy.tab.c" break; - case 92: /* edgeparam: EP_LA number */ -#line 435 "src/vendor/cigraph/src/io/pajek-parser.y" + case 76: /* edgeparam: EP_LA number */ +#line 402 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("labeldegree", (yyvsp[0].realnum), context)); - } -#line 2309 "yy.tab.c" - break; - - case 93: /* edgeparam: EP_SIZE number */ -#line 438 "src/vendor/cigraph/src/io/pajek-parser.y" - { /* what is this??? */ - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("arrowsize", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("labeldegree", (yyvsp[0].realnum), context)); } -#line 2317 "yy.tab.c" +#line 2209 "yy.tab.c" break; - case 94: /* edgeparam: EP_FOS number */ -#line 441 "src/vendor/cigraph/src/io/pajek-parser.y" + case 77: /* edgeparam: EP_FOS number */ +#line 405 "src/vendor/cigraph/src/io/pajek-parser.y" { - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("fontsize", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("fontsize", (yyvsp[0].realnum), context)); } -#line 2325 "yy.tab.c" +#line 2217 "yy.tab.c" break; - case 95: /* $@9: %empty */ -#line 446 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=4; } -#line 2331 "yy.tab.c" - break; - - case 96: /* epword: EP_A $@9 epwordpar */ -#line 446 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=2; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_edge_attribute("arrowtype", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 78: /* epword: EP_A parstrval */ +#line 410 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_edge_attribute("arrowtype", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2340 "yy.tab.c" - break; - - case 97: /* $@10: %empty */ -#line 450 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=4; } -#line 2346 "yy.tab.c" +#line 2225 "yy.tab.c" break; - case 98: /* epword: EP_P $@10 epwordpar */ -#line 450 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=2; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_edge_attribute("linepattern", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 79: /* epword: EP_P parstrval */ +#line 413 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_edge_attribute("linepattern", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2355 "yy.tab.c" - break; - - case 99: /* $@11: %empty */ -#line 454 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=4; } -#line 2361 "yy.tab.c" +#line 2233 "yy.tab.c" break; - case 100: /* epword: EP_L $@11 epwordpar */ -#line 454 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=2; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_edge_attribute("label", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 80: /* epword: EP_L parstrval */ +#line 416 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_edge_attribute("label", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2370 "yy.tab.c" - break; - - case 101: /* $@12: %empty */ -#line 458 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=4; } -#line 2376 "yy.tab.c" +#line 2241 "yy.tab.c" break; - case 102: /* epword: EP_LC $@12 epwordpar */ -#line 458 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=2; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_edge_attribute("labelcolor", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 81: /* epword: EP_LC parstrval */ +#line 419 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_edge_attribute("labelcolor", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2385 "yy.tab.c" +#line 2249 "yy.tab.c" break; - case 103: /* $@13: %empty */ -#line 462 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=4; } -#line 2391 "yy.tab.c" + case 82: /* epword: EP_C parstrval */ +#line 422 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_edge_attribute("color", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + } +#line 2257 "yy.tab.c" break; - case 104: /* epword: EP_C $@13 epwordpar */ -#line 462 "src/vendor/cigraph/src/io/pajek-parser.y" - { - context->mode=2; - IGRAPH_YY_CHECK(igraph_i_pajek_add_string_edge_attribute("color", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + case 83: /* epword: EP_FONT parstrval */ +#line 425 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(add_string_edge_attribute("font", (yyvsp[0].string).str, (yyvsp[0].string).len, context)); } -#line 2400 "yy.tab.c" +#line 2265 "yy.tab.c" break; - case 105: /* epwordpar: word */ -#line 468 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=2; (yyval.string)=(yyvsp[0].string); } -#line 2406 "yy.tab.c" + case 84: /* epword: parname parstrval */ +#line 428 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_FINALLY(igraph_free, (yyvsp[-1].dynstr)); + if (is_standard_eattr((yyvsp[-1].dynstr))) { + IGRAPH_YY_CHECK(deconflict_attrname(&(yyvsp[-1].dynstr))); + /* update address on finally stack */ + IGRAPH_FINALLY_CLEAN(1); + IGRAPH_FINALLY(igraph_free, (yyvsp[-1].dynstr)); + } + IGRAPH_YY_CHECK(add_string_edge_attribute( + (yyvsp[-1].dynstr), (yyvsp[0].string).str, (yyvsp[0].string).len, context)); + IGRAPH_FREE((yyvsp[-1].dynstr)); + IGRAPH_FINALLY_CLEAN(1); + } +#line 2283 "yy.tab.c" break; - case 106: /* arcslist: "*arcslist line" "end of line" arcslistlines */ -#line 470 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->directed=1; } -#line 2412 "yy.tab.c" + case 85: /* arcslist: "*Arcslist line" "end of line" arcslistlines */ +#line 443 "src/vendor/cigraph/src/io/pajek-parser.y" + { context->directed=true; } +#line 2289 "yy.tab.c" break; - case 113: /* arclistfrom: longint */ -#line 478 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=0; context->actfrom=labs((yyvsp[0].intnum))-1; } -#line 2418 "yy.tab.c" + case 91: /* arclistfrom: integer */ +#line 451 "src/vendor/cigraph/src/io/pajek-parser.y" + { context->actfrom=labs((yyvsp[0].intnum))-1; } +#line 2295 "yy.tab.c" break; - case 114: /* arclistto: longint */ -#line 480 "src/vendor/cigraph/src/io/pajek-parser.y" + case 92: /* arclistto: integer */ +#line 453 "src/vendor/cigraph/src/io/pajek-parser.y" { IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, context->actfrom)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, labs((yyvsp[0].intnum))-1)); } -#line 2427 "yy.tab.c" +#line 2304 "yy.tab.c" break; - case 115: /* edgeslist: "*edgeslist line" "end of line" edgelistlines */ -#line 485 "src/vendor/cigraph/src/io/pajek-parser.y" + case 93: /* edgeslist: "*Edgeslist line" "end of line" edgelistlines */ +#line 458 "src/vendor/cigraph/src/io/pajek-parser.y" { context->directed=0; } -#line 2433 "yy.tab.c" +#line 2310 "yy.tab.c" break; - case 122: /* edgelistfrom: longint */ -#line 493 "src/vendor/cigraph/src/io/pajek-parser.y" - { context->mode=0; context->actfrom=labs((yyvsp[0].intnum))-1; } -#line 2439 "yy.tab.c" + case 99: /* edgelistfrom: integer */ +#line 466 "src/vendor/cigraph/src/io/pajek-parser.y" + { context->actfrom=labs((yyvsp[0].intnum))-1; } +#line 2316 "yy.tab.c" break; - case 123: /* edgelistto: longint */ -#line 495 "src/vendor/cigraph/src/io/pajek-parser.y" + case 100: /* edgelistto: integer */ +#line 468 "src/vendor/cigraph/src/io/pajek-parser.y" { IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, context->actfrom)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, labs((yyvsp[0].intnum))-1)); } -#line 2448 "yy.tab.c" +#line 2325 "yy.tab.c" break; - case 125: /* matrixline: "*matrix line" */ -#line 504 "src/vendor/cigraph/src/io/pajek-parser.y" + case 102: /* matrixline: "*Matrix line" */ +#line 477 "src/vendor/cigraph/src/io/pajek-parser.y" { context->actfrom=0; context->actto=0; context->directed=(context->vcount2==0); } -#line 2457 "yy.tab.c" +#line 2334 "yy.tab.c" break; - case 128: /* adjmatrixline: adjmatrixnumbers "end of line" */ -#line 511 "src/vendor/cigraph/src/io/pajek-parser.y" + case 105: /* adjmatrixline: adjmatrixnumbers "end of line" */ +#line 484 "src/vendor/cigraph/src/io/pajek-parser.y" { context->actfrom++; context->actto=0; } -#line 2463 "yy.tab.c" +#line 2340 "yy.tab.c" break; - case 131: /* adjmatrixentry: number */ -#line 515 "src/vendor/cigraph/src/io/pajek-parser.y" + case 108: /* adjmatrixentry: number */ +#line 488 "src/vendor/cigraph/src/io/pajek-parser.y" { if ((yyvsp[0].realnum) != 0) { if (context->vcount2==0) { context->actedge++; - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("weight", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("weight", (yyvsp[0].realnum), context)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, context->actfrom)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, context->actto)); } else if (context->vcount2 + context->actto < context->vcount) { context->actedge++; - IGRAPH_YY_CHECK(igraph_i_pajek_add_numeric_edge_attribute("weight", (yyvsp[0].realnum), context)); + IGRAPH_YY_CHECK(add_numeric_edge_attribute("weight", (yyvsp[0].realnum), context)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, context->actfrom)); IGRAPH_YY_CHECK(igraph_vector_int_push_back(context->vector, context->vcount2+context->actto)); @@ -2481,11 +2358,11 @@ YYLTYPE yylloc = yyloc_default; } context->actto++; } -#line 2485 "yy.tab.c" +#line 2362 "yy.tab.c" break; - case 132: /* longint: "number" */ -#line 535 "src/vendor/cigraph/src/io/pajek-parser.y" + case 109: /* integer: "number" */ +#line 508 "src/vendor/cigraph/src/io/pajek-parser.y" { igraph_integer_t val; IGRAPH_YY_CHECK(igraph_i_parse_integer(igraph_pajek_yyget_text(scanner), @@ -2493,11 +2370,11 @@ YYLTYPE yylloc = yyloc_default; &val)); (yyval.intnum)=val; } -#line 2497 "yy.tab.c" +#line 2374 "yy.tab.c" break; - case 133: /* number: "number" */ -#line 543 "src/vendor/cigraph/src/io/pajek-parser.y" + case 110: /* number: "number" */ +#line 516 "src/vendor/cigraph/src/io/pajek-parser.y" { igraph_real_t val; IGRAPH_YY_CHECK(igraph_i_parse_real(igraph_pajek_yyget_text(scanner), @@ -2505,32 +2382,46 @@ YYLTYPE yylloc = yyloc_default; &val)); (yyval.realnum)=val; } -#line 2509 "yy.tab.c" +#line 2386 "yy.tab.c" + break; + + case 111: /* parname: word */ +#line 524 "src/vendor/cigraph/src/io/pajek-parser.y" + { + IGRAPH_YY_CHECK(make_dynstr((yyvsp[0].string).str, (yyvsp[0].string).len, &(yyval.dynstr))); +} +#line 2394 "yy.tab.c" break; - case 134: /* word: ALNUM */ -#line 551 "src/vendor/cigraph/src/io/pajek-parser.y" + case 112: /* parstrval: word */ +#line 528 "src/vendor/cigraph/src/io/pajek-parser.y" + { (yyval.string)=(yyvsp[0].string); } +#line 2400 "yy.tab.c" + break; + + case 113: /* word: "word" */ +#line 530 "src/vendor/cigraph/src/io/pajek-parser.y" { (yyval.string).str=igraph_pajek_yyget_text(scanner); (yyval.string).len=igraph_pajek_yyget_leng(scanner); } -#line 2516 "yy.tab.c" +#line 2407 "yy.tab.c" break; - case 135: /* word: "number" */ -#line 553 "src/vendor/cigraph/src/io/pajek-parser.y" + case 114: /* word: "number" */ +#line 532 "src/vendor/cigraph/src/io/pajek-parser.y" { (yyval.string).str=igraph_pajek_yyget_text(scanner); (yyval.string).len=igraph_pajek_yyget_leng(scanner); } -#line 2523 "yy.tab.c" +#line 2414 "yy.tab.c" break; - case 136: /* word: QSTR */ -#line 555 "src/vendor/cigraph/src/io/pajek-parser.y" + case 115: /* word: "quoted string" */ +#line 534 "src/vendor/cigraph/src/io/pajek-parser.y" { (yyval.string).str=igraph_pajek_yyget_text(scanner)+1; (yyval.string).len=igraph_pajek_yyget_leng(scanner)-2; } -#line 2530 "yy.tab.c" +#line 2421 "yy.tab.c" break; -#line 2534 "yy.tab.c" +#line 2425 "yy.tab.c" default: break; } @@ -2759,7 +2650,7 @@ YYLTYPE yylloc = yyloc_default; return yyresult; } -#line 558 "src/vendor/cigraph/src/io/pajek-parser.y" +#line 537 "src/vendor/cigraph/src/io/pajek-parser.y" int igraph_pajek_yyerror(YYLTYPE* locp, @@ -2773,12 +2664,12 @@ int igraph_pajek_yyerror(YYLTYPE* locp, /* TODO: NA's */ -static igraph_error_t igraph_i_pajek_add_numeric_attribute(igraph_trie_t *names, - igraph_vector_ptr_t *attrs, - igraph_integer_t count, - const char *attrname, - igraph_integer_t vid, - igraph_real_t number) { +static igraph_error_t add_numeric_attribute(igraph_trie_t *names, + igraph_vector_ptr_t *attrs, + igraph_integer_t count, + const char *attrname, + igraph_integer_t elem_id, + igraph_real_t number) { igraph_integer_t attrsize = igraph_trie_size(names); igraph_integer_t id; igraph_vector_t *na; @@ -2787,40 +2678,39 @@ static igraph_error_t igraph_i_pajek_add_numeric_attribute(igraph_trie_t *names, IGRAPH_CHECK(igraph_trie_get(names, attrname, &id)); if (id == attrsize) { /* add a new attribute */ - rec=IGRAPH_CALLOC(1, igraph_attribute_record_t); - if (! rec) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + rec = IGRAPH_CALLOC(1, igraph_attribute_record_t); + CHECK_OOM_RP(rec); IGRAPH_FINALLY(igraph_free, rec); - na=IGRAPH_CALLOC(1, igraph_vector_t); - if (! na) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + + na = IGRAPH_CALLOC(1, igraph_vector_t); + CHECK_OOM_RP(na); IGRAPH_FINALLY(igraph_free, na); IGRAPH_VECTOR_INIT_FINALLY(na, count); - rec->name=strdup(attrname); - if (! rec->name) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + + rec->name = strdup(attrname); + CHECK_OOM_RP(rec->name); IGRAPH_FINALLY(igraph_free, (void *) rec->name); - rec->type=IGRAPH_ATTRIBUTE_NUMERIC; - rec->value=na; + + rec->type = IGRAPH_ATTRIBUTE_NUMERIC; + rec->value = na; + IGRAPH_CHECK(igraph_vector_ptr_push_back(attrs, rec)); IGRAPH_FINALLY_CLEAN(4); /* ownership of rec transferred to attrs */ } - rec=VECTOR(*attrs)[id]; - na=(igraph_vector_t*)rec->value; - if (igraph_vector_size(na) == vid) { + + rec = VECTOR(*attrs)[id]; + na = (igraph_vector_t *) rec->value; + if (igraph_vector_size(na) == elem_id) { IGRAPH_CHECK(igraph_vector_push_back(na, number)); - } else if (igraph_vector_size(na) < vid) { + } else if (igraph_vector_size(na) < elem_id) { igraph_integer_t origsize=igraph_vector_size(na); - IGRAPH_CHECK(igraph_vector_resize(na, vid+1)); + IGRAPH_CHECK(igraph_vector_resize(na, elem_id+1)); for (;origsize 21) { + IGRAPH_ERROR("Too many attributes in Pajek file.", IGRAPH_PARSEERROR); } +#endif + + /* add a new attribute */ + rec = IGRAPH_CALLOC(1, igraph_attribute_record_t); + CHECK_OOM_RP(rec); IGRAPH_FINALLY(igraph_free, rec); - na=IGRAPH_CALLOC(1, igraph_strvector_t); - if (! na) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + + na = IGRAPH_CALLOC(1, igraph_strvector_t); + CHECK_OOM_RP(na); IGRAPH_FINALLY(igraph_free, na); IGRAPH_STRVECTOR_INIT_FINALLY(na, count); - rec->name=strdup(attrname); - if (! rec->name) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + + rec->name = strdup(attrname); + CHECK_OOM_RP(rec->name); IGRAPH_FINALLY(igraph_free, (char *) rec->name); - rec->type=IGRAPH_ATTRIBUTE_STRING; - rec->value=na; + + rec->type = IGRAPH_ATTRIBUTE_STRING; + rec->value = na; + IGRAPH_CHECK(igraph_vector_ptr_push_back(attrs, rec)); IGRAPH_FINALLY_CLEAN(4); /* ownership of rec transferred to attrs */ } - rec=VECTOR(*attrs)[id]; - na=(igraph_strvector_t*)rec->value; - if (igraph_strvector_size(na) <= vid) { - IGRAPH_CHECK(igraph_strvector_resize(na, vid+1)); + + rec = VECTOR(*attrs)[id]; + na = (igraph_strvector_t *) rec->value; + if (igraph_strvector_size(na) <= elem_id) { + IGRAPH_CHECK(igraph_strvector_resize(na, elem_id+1)); } - IGRAPH_CHECK(igraph_strvector_set_len(na, vid, str, str_len)); + IGRAPH_CHECK(igraph_strvector_set_len(na, elem_id, str, str_len)); return IGRAPH_SUCCESS; } -static igraph_error_t igraph_i_pajek_add_string_vertex_attribute(const char *name, - const char *value, - size_t len, - igraph_i_pajek_parsedata_t *context) { - +static igraph_error_t add_string_vertex_attribute(const char *name, + const char *value, + size_t len, + igraph_i_pajek_parsedata_t *context) { - return igraph_i_pajek_add_string_attribute(context->vertex_attribute_names, - context->vertex_attributes, - context->vcount, - name, context->actvertex-1, - value, len); + return add_string_attribute(context->vertex_attribute_names, + context->vertex_attributes, + context->vcount, + name, context->actvertex-1, + value, len); } -static igraph_error_t igraph_i_pajek_add_string_edge_attribute(const char *name, - const char *value, - size_t len, - igraph_i_pajek_parsedata_t *context) { +static igraph_error_t add_string_edge_attribute(const char *name, + const char *value, + size_t len, + igraph_i_pajek_parsedata_t *context) { - return igraph_i_pajek_add_string_attribute(context->edge_attribute_names, - context->edge_attributes, - context->actedge, - name, context->actedge-1, - value, len); + return add_string_attribute(context->edge_attribute_names, + context->edge_attributes, + context->actedge, + name, context->actedge-1, + value, len); } -static igraph_error_t igraph_i_pajek_add_numeric_vertex_attribute(const char *name, - igraph_real_t value, - igraph_i_pajek_parsedata_t *context) { +static igraph_error_t add_numeric_vertex_attribute(const char *name, + igraph_real_t value, + igraph_i_pajek_parsedata_t *context) { - return igraph_i_pajek_add_numeric_attribute(context->vertex_attribute_names, - context->vertex_attributes, - context->vcount, - name, context->actvertex-1, - value); + return add_numeric_attribute(context->vertex_attribute_names, + context->vertex_attributes, + context->vcount, + name, context->actvertex-1, + value); } -static igraph_error_t igraph_i_pajek_add_numeric_edge_attribute(const char *name, - igraph_real_t value, - igraph_i_pajek_parsedata_t *context) { +static igraph_error_t add_numeric_edge_attribute(const char *name, + igraph_real_t value, + igraph_i_pajek_parsedata_t *context) { - return igraph_i_pajek_add_numeric_attribute(context->edge_attribute_names, - context->edge_attributes, - context->actedge, - name, context->actedge-1, - value); + return add_numeric_attribute(context->edge_attribute_names, + context->edge_attributes, + context->actedge, + name, context->actedge-1, + value); } -static igraph_error_t igraph_i_pajek_add_bipartite_type(igraph_i_pajek_parsedata_t *context) { +static igraph_error_t add_bipartite_type(igraph_i_pajek_parsedata_t *context) { const char *attrname="type"; igraph_trie_t *names=context->vertex_attribute_names; igraph_vector_ptr_t *attrs=context->vertex_attributes; - igraph_integer_t i, n=context->vcount, n1=context->vcount2; + igraph_integer_t n=context->vcount, n1=context->vcount2; igraph_integer_t attrid, attrsize = igraph_trie_size(names); igraph_attribute_record_t *rec; igraph_vector_bool_t *na; @@ -2937,48 +2846,47 @@ static igraph_error_t igraph_i_pajek_add_bipartite_type(igraph_i_pajek_parsedata } IGRAPH_CHECK(igraph_trie_get(names, attrname, &attrid)); + /* It should not be possible for the "type" attribute to be already * present at this point. */ IGRAPH_ASSERT(attrid == attrsize); /* add a new attribute */ - rec=IGRAPH_CALLOC(1, igraph_attribute_record_t); - if (! rec) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + rec = IGRAPH_CALLOC(1, igraph_attribute_record_t); + CHECK_OOM_RP(rec); IGRAPH_FINALLY(igraph_free, rec); - na=IGRAPH_CALLOC(1, igraph_vector_bool_t); - if (! na) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + + na = IGRAPH_CALLOC(1, igraph_vector_bool_t); + CHECK_OOM_RP(na); IGRAPH_FINALLY(igraph_free, na); IGRAPH_VECTOR_BOOL_INIT_FINALLY(na, n); - rec->name=strdup(attrname); - if (! rec->name) { - IGRAPH_ERROR("Out of memory while parsing Pajek file.", IGRAPH_ENOMEM); - } + + rec->name = strdup(attrname); + CHECK_OOM_RP(rec->name); IGRAPH_FINALLY(igraph_free, (char *) rec->name); - rec->type=IGRAPH_ATTRIBUTE_BOOLEAN; - rec->value=na; + + rec->type = IGRAPH_ATTRIBUTE_BOOLEAN; + rec->value = na; + IGRAPH_CHECK(igraph_vector_ptr_push_back(attrs, rec)); IGRAPH_FINALLY_CLEAN(4); /* ownership of 'rec' transferred to 'attrs' */ - for (i=0; ivector; - igraph_integer_t i, n1=context->vcount2; + igraph_integer_t n1=context->vcount2; igraph_integer_t ne=igraph_vector_int_size(edges); - for (i=0; i n1 && v2 > n1) ) { @@ -2988,3 +2896,63 @@ static igraph_error_t igraph_i_pajek_check_bipartite(igraph_i_pajek_parsedata_t return IGRAPH_SUCCESS; } + +/* Check if attrname is a standard vertex attribute name used by igraph + for Pajek data. All of these must be listed here to prevent overwriting + standard attributes, or crashes due to incompatible attribute types. */ +static igraph_bool_t is_standard_vattr(const char *attrname) { + const char *names[] = { + /* vertex names: */ + "id", /* TODO: remove for 0.11 */ "name", + /* other vertex attributes: */ + "type", "x", "y", "z", + /* vertex parameters: */ + "xfact", "yfact", + "labeldist", "labeldegree2", "framewidth", + "fontsize", "rotation", "radius", + "diamondratio", "labeldegree", + "font", "url", "color", "framecolor", + "labelcolor" + }; + for (size_t i=0; i < sizeof(names) / sizeof(names[0]); i++) { + if (strcmp(attrname, names[i]) == 0) { + return true; + } + } + return false; +} + +/* Check if attrname is a standard edge attribute name used by igraph + for Pajek data. All of these must be listed here to prevent overwriting + standard attributes, or crashes due to incompatible attribute types. */ +static igraph_bool_t is_standard_eattr(const char *attrname) { + const char *names[] = { + /* other edge attributes: */ + "weight", + /* edge parameters: */ + "arrowsize", "edgewidth", "hook1", "hook2", + "angle1", "angle2", "velocity1", "velocity2", + "arrowpos", "labelpos", "labelangle", + "labelangle2", "labeldegree", "fontsize", "font", + "arrowtype", "linepattern", "label", "labelcolor", + "color" + }; + for (size_t i=0; i < sizeof(names) / sizeof(names[0]); i++) { + if (strcmp(attrname, names[i]) == 0) { + return true; + } + } + return false; +} + +/* Add a _ character at the end of an attribute name to avoid conflict + * with standard Pajek attributes. */ +static igraph_error_t deconflict_attrname(char **attrname) { + size_t len = strlen(*attrname); + char *tmp = IGRAPH_REALLOC(*attrname, len+2, char); + CHECK_OOM_RP(tmp); + tmp[len] = '_'; + tmp[len+1] = '\0'; + *attrname = tmp; + return IGRAPH_SUCCESS; +} diff --git a/src/vendor/io/parsers/gml-lexer.h b/src/vendor/io/parsers/gml-lexer.h index 5d132c35427..a0735ebd707 100644 --- a/src/vendor/io/parsers/gml-lexer.h +++ b/src/vendor/io/parsers/gml-lexer.h @@ -729,7 +729,7 @@ extern int yylex \ #undef yyTABLES_NAME #endif -#line 103 "src/vendor/cigraph/src/io/gml-lexer.l" +#line 105 "src/vendor/cigraph/src/io/gml-lexer.l" #line 736 "src/vendor/io/parsers/gml-lexer.h" diff --git a/src/vendor/io/parsers/gml-parser.h b/src/vendor/io/parsers/gml-parser.h index c9e457b32e8..b42a67b404d 100644 --- a/src/vendor/io/parsers/gml-parser.h +++ b/src/vendor/io/parsers/gml-parser.h @@ -68,7 +68,7 @@ extern int igraph_gml_yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 94 "src/vendor/cigraph/src/io/gml-parser.y" +#line 93 "src/vendor/cigraph/src/io/gml-parser.y" char *str; igraph_gml_tree_t *tree; diff --git a/src/vendor/io/parsers/lgl-lexer.h b/src/vendor/io/parsers/lgl-lexer.h index 07f16e3ebd1..53c6498a0b6 100644 --- a/src/vendor/io/parsers/lgl-lexer.h +++ b/src/vendor/io/parsers/lgl-lexer.h @@ -457,6 +457,7 @@ void yyfree ( void * , yyscan_t yyscanner ); #ifdef YY_HEADER_EXPORT_START_CONDITIONS #define INITIAL 0 +#define LINE 1 #endif @@ -728,9 +729,9 @@ extern int yylex \ #undef yyTABLES_NAME #endif -#line 101 "src/vendor/cigraph/src/io/lgl-lexer.l" +#line 98 "src/vendor/cigraph/src/io/lgl-lexer.l" -#line 735 "src/vendor/io/parsers/lgl-lexer.h" +#line 736 "src/vendor/io/parsers/lgl-lexer.h" #undef igraph_lgl_yyIN_HEADER #endif /* igraph_lgl_yyHEADER_H */ diff --git a/src/vendor/io/parsers/ncol-lexer.h b/src/vendor/io/parsers/ncol-lexer.h index a5e5fb31ca6..4c70d004fd7 100644 --- a/src/vendor/io/parsers/ncol-lexer.h +++ b/src/vendor/io/parsers/ncol-lexer.h @@ -457,6 +457,7 @@ void yyfree ( void * , yyscan_t yyscanner ); #ifdef YY_HEADER_EXPORT_START_CONDITIONS #define INITIAL 0 +#define LINE 1 #endif @@ -728,9 +729,9 @@ extern int yylex \ #undef yyTABLES_NAME #endif -#line 99 "src/vendor/cigraph/src/io/ncol-lexer.l" +#line 95 "src/vendor/cigraph/src/io/ncol-lexer.l" -#line 735 "src/vendor/io/parsers/ncol-lexer.h" +#line 736 "src/vendor/io/parsers/ncol-lexer.h" #undef igraph_ncol_yyIN_HEADER #endif /* igraph_ncol_yyHEADER_H */ diff --git a/src/vendor/io/parsers/pajek-lexer.h b/src/vendor/io/parsers/pajek-lexer.h index 244cd0c2cc1..6b8470955a1 100644 --- a/src/vendor/io/parsers/pajek-lexer.h +++ b/src/vendor/io/parsers/pajek-lexer.h @@ -457,7 +457,11 @@ void yyfree ( void * , yyscan_t yyscanner ); #ifdef YY_HEADER_EXPORT_START_CONDITIONS #define INITIAL 0 -#define netline 1 +#define unknown 1 +#define unknown_line 2 +#define bom 3 +#define vert 4 +#define edge 5 #endif @@ -729,9 +733,9 @@ extern int yylex \ #undef yyTABLES_NAME #endif -#line 152 "src/vendor/cigraph/src/io/pajek-lexer.l" +#line 195 "src/vendor/cigraph/src/io/pajek-lexer.l" -#line 736 "src/vendor/io/parsers/pajek-lexer.h" +#line 740 "src/vendor/io/parsers/pajek-lexer.h" #undef igraph_pajek_yyIN_HEADER #endif /* igraph_pajek_yyHEADER_H */ diff --git a/src/vendor/io/parsers/pajek-parser.h b/src/vendor/io/parsers/pajek-parser.h index 2e60cdc749f..46a27e2663d 100644 --- a/src/vendor/io/parsers/pajek-parser.h +++ b/src/vendor/io/parsers/pajek-parser.h @@ -56,54 +56,51 @@ extern int igraph_pajek_yydebug; YYUNDEF = 257, /* "invalid token" */ NEWLINE = 258, /* "end of line" */ NUM = 259, /* "number" */ - ALNUM = 260, /* ALNUM */ - QSTR = 261, /* QSTR */ - PSTR = 262, /* PSTR */ - NETWORKLINE = 263, /* "*network line" */ - NET_TITLE = 264, /* NET_TITLE */ - VERTICESLINE = 265, /* "*vertices line" */ - ARCSLINE = 266, /* "*arcs line" */ - EDGESLINE = 267, /* "*edges line" */ - ARCSLISTLINE = 268, /* "*arcslist line" */ - EDGESLISTLINE = 269, /* "*edgeslist line" */ - MATRIXLINE = 270, /* "*matrix line" */ - ERROR = 271, /* ERROR */ - VP_X_FACT = 272, /* VP_X_FACT */ - VP_Y_FACT = 273, /* VP_Y_FACT */ - VP_IC = 274, /* VP_IC */ - VP_BC = 275, /* VP_BC */ - VP_LC = 276, /* VP_LC */ - VP_LR = 277, /* VP_LR */ - VP_LPHI = 278, /* VP_LPHI */ - VP_BW = 279, /* VP_BW */ - VP_FOS = 280, /* VP_FOS */ - VP_PHI = 281, /* VP_PHI */ - VP_R = 282, /* VP_R */ - VP_Q = 283, /* VP_Q */ - VP_LA = 284, /* VP_LA */ - VP_FONT = 285, /* VP_FONT */ - VP_URL = 286, /* VP_URL */ - VP_SIZE = 287, /* VP_SIZE */ + ALNUM = 260, /* "word" */ + QSTR = 261, /* "quoted string" */ + NETWORKLINE = 262, /* "*Network line" */ + VERTICESLINE = 263, /* "*Vertices line" */ + ARCSLINE = 264, /* "*Arcs line" */ + EDGESLINE = 265, /* "*Edges line" */ + ARCSLISTLINE = 266, /* "*Arcslist line" */ + EDGESLISTLINE = 267, /* "*Edgeslist line" */ + MATRIXLINE = 268, /* "*Matrix line" */ + ERROR = 269, /* ERROR */ + VP_X_FACT = 270, /* VP_X_FACT */ + VP_Y_FACT = 271, /* VP_Y_FACT */ + VP_PHI = 272, /* VP_PHI */ + VP_R = 273, /* VP_R */ + VP_Q = 274, /* VP_Q */ + VP_IC = 275, /* VP_IC */ + VP_BC = 276, /* VP_BC */ + VP_BW = 277, /* VP_BW */ + VP_LC = 278, /* VP_LC */ + VP_LA = 279, /* VP_LA */ + VP_LR = 280, /* VP_LR */ + VP_LPHI = 281, /* VP_LPHI */ + VP_FOS = 282, /* VP_FOS */ + VP_FONT = 283, /* VP_FONT */ + VP_URL = 284, /* VP_URL */ + EP_H1 = 285, /* EP_H1 */ + EP_H2 = 286, /* EP_H2 */ + EP_W = 287, /* EP_W */ EP_C = 288, /* EP_C */ - EP_S = 289, /* EP_S */ + EP_P = 289, /* EP_P */ EP_A = 290, /* EP_A */ - EP_W = 291, /* EP_W */ - EP_H1 = 292, /* EP_H1 */ - EP_H2 = 293, /* EP_H2 */ - EP_A1 = 294, /* EP_A1 */ - EP_A2 = 295, /* EP_A2 */ - EP_K1 = 296, /* EP_K1 */ - EP_K2 = 297, /* EP_K2 */ - EP_AP = 298, /* EP_AP */ - EP_P = 299, /* EP_P */ - EP_L = 300, /* EP_L */ - EP_LP = 301, /* EP_LP */ - EP_LR = 302, /* EP_LR */ - EP_LPHI = 303, /* EP_LPHI */ - EP_LC = 304, /* EP_LC */ - EP_LA = 305, /* EP_LA */ - EP_SIZE = 306, /* EP_SIZE */ - EP_FOS = 307 /* EP_FOS */ + EP_S = 291, /* EP_S */ + EP_A1 = 292, /* EP_A1 */ + EP_K1 = 293, /* EP_K1 */ + EP_A2 = 294, /* EP_A2 */ + EP_K2 = 295, /* EP_K2 */ + EP_AP = 296, /* EP_AP */ + EP_L = 297, /* EP_L */ + EP_LP = 298, /* EP_LP */ + EP_LR = 299, /* EP_LR */ + EP_LPHI = 300, /* EP_LPHI */ + EP_LC = 301, /* EP_LC */ + EP_LA = 302, /* EP_LA */ + EP_FOS = 303, /* EP_FOS */ + EP_FONT = 304 /* EP_FONT */ }; typedef enum yytokentype yytoken_kind_t; #endif @@ -112,7 +109,7 @@ extern int igraph_pajek_yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 111 "src/vendor/cigraph/src/io/pajek-parser.y" +#line 116 "src/vendor/cigraph/src/io/pajek-parser.y" igraph_integer_t intnum; igraph_real_t realnum; @@ -120,8 +117,9 @@ union YYSTYPE char *str; size_t len; } string; + char *dynstr; -#line 125 "yy.tab.h" +#line 123 "yy.tab.h" }; typedef union YYSTYPE YYSTYPE; diff --git a/src/vendor/uuid/config.h b/src/vendor/uuid/config.h new file mode 100644 index 00000000000..ddb75b00d71 --- /dev/null +++ b/src/vendor/uuid/config.h @@ -0,0 +1,2 @@ +// https://github.com/igraph/rigraph/pull/840#issuecomment-1696078490 +#define HAVE_UNISTD_H 1 diff --git a/tests/testthat/_snaps/graph.bfs.md b/tests/testthat/_snaps/graph.bfs.md index 78f29734a19..c3c9dab82e4 100644 --- a/tests/testthat/_snaps/graph.bfs.md +++ b/tests/testthat/_snaps/graph.bfs.md @@ -36,7 +36,7 @@ $dist a b c z d - -3 0 1 -3 -3 + -1 0 1 -1 -1 $neimode [1] "out" diff --git a/tests/testthat/test-coloring.R b/tests/testthat/test-coloring.R index 62570ac5f9a..c8c799ed9f6 100644 --- a/tests/testthat/test-coloring.R +++ b/tests/testthat/test-coloring.R @@ -8,6 +8,10 @@ test_that("greedy_vertex_coloring works", { greedy_vertex_coloring(g, heuristic = "colored_neighbors"), equals(c(1, rep(2, vcount(g) - 1))) ) + expect_that( + greedy_vertex_coloring(g, heuristic = "dsatur"), + equals(c(1, rep(2, vcount(g) - 1))) + ) }) test_that("greedy_vertex_coloring works on named graphs", { diff --git a/tests/testthat/test-trees.R b/tests/testthat/test-trees.R index 79aece776cc..3c09f18bf47 100644 --- a/tests/testthat/test-trees.R +++ b/tests/testthat/test-trees.R @@ -1,4 +1,6 @@ test_that("is_tree works for non-trees", { + skip("Waiting for #935") + g <- make_graph("zachary") expect_false(is_tree(g)) expect_equal( @@ -53,6 +55,22 @@ test_that("a graph with a single vertex and no edges is tree", { expect_true(is_tree(make_empty_graph(1))) }) +test_that("is_forest takes edge directions into account correctly", { + g <- make_graph(c(1,2, 2,3, 2,4, 5,4), n = 6, directed = TRUE) + + expect_true(is_forest(g, mode = "all")) + expect_false(is_forest(g, mode = "out")) + expect_false(is_forest(g, mode = "in")) +}) + +test_that("the null graph is a forest", { + expect_true(is_forest(make_empty_graph(0))) +}) + +test_that("a graph with a single vertex and no edges is a forest", { + expect_true(is_forest(make_empty_graph(1))) +}) + test_that("to_prufer and make_from_prufer works for trees", { g <- make_tree(13, 3, mode = "undirected") seq <- to_prufer(g) diff --git a/tools/build-requirements.txt b/tools/build-requirements.txt index 144cd2eb88b..d9a2c14cfcf 100644 --- a/tools/build-requirements.txt +++ b/tools/build-requirements.txt @@ -3,4 +3,4 @@ # environment to detect when to re-create the virtualenv so the hash # needs to change whenever a package is updated. -git+https://github.com/igraph/stimulus@0.13.0#egg=stimulus +git+https://github.com/igraph/stimulus@0.18.0#egg=stimulus diff --git a/tools/fix-lexers.sh b/tools/fix-lexers.sh index c451801eef2..1703c567566 100755 --- a/tools/fix-lexers.sh +++ b/tools/fix-lexers.sh @@ -5,7 +5,7 @@ set -e -for fname in src/core/io/*-lexer.c; do +for fname in src/vendor/io/*-lexer.c; do # Remove unused exit points from the lexer cat ${fname} | grep -v '^\s*exit.*YY_EXIT_FAILURE' >${fname}.new mv ${fname}.new ${fname} @@ -15,18 +15,11 @@ for fname in src/core/io/*-lexer.c; do mv ${fname}.new ${fname} done -for fname in src/core/io/*-lexer.c src/core/io/*-parser.c; do - # the CMake build system puts the generated parsers in build/core/io/parsers. - # Here it is easier to put stuff in src/core/io so we rewrite the includes - cat ${fname} | sed -e 's,io/parsers/,io/,g' >${fname}.new - mv ${fname}.new ${fname} -done - -for fname in src/core/io/*-parser.c; do +for fname in src/vendor/io/*-parser.c; do # Bison 3.8.2 (and maybe other versions) refer to #include yy.tab.h in the # generated file; we need to replace this with the real header name header=`basename ${fname} .c`.h - cat ${fname} | sed -e 's,^#include.*yy.tab.h.*$,#include "io/'"${header}"'",g' >${fname}.new + cat ${fname} | sed -e 's,^#include.*yy.tab.h.*$,#include "io/parsers/'"${header}"'",g' >${fname}.new mv ${fname}.new ${fname} done diff --git a/tools/stimulus/Makevars.in b/tools/stimulus/Makevars.in index 1481b386484..114f973c263 100644 --- a/tools/stimulus/Makevars.in +++ b/tools/stimulus/Makevars.in @@ -2,11 +2,10 @@ PKG_CFLAGS=$(C_VISIBILITY) PKG_CXXFLAGS=$(CXX_VISIBILITY) PKG_FFLAGS=$(F_VISIBILITY) -PKG_CPPFLAGS=-DUSING_R -I. -Icore -Iinclude -Ivendor \ +PKG_CPPFLAGS=-DUSING_R -I. -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/Makevars.ucrt b/tools/stimulus/Makevars.ucrt index e6142d60eeb..0cb7c46f87e 100644 --- a/tools/stimulus/Makevars.ucrt +++ b/tools/stimulus/Makevars.ucrt @@ -6,9 +6,8 @@ PKG_CPPFLAGS = -I${LIB_XML}/include/libxml2 -I${LIB_XML}/include -DLIBXML_STATIC -DHAVE_FMEMOPEN=0 -DHAVE_OPEN_MEMSTREAM=0 -DHAVE_RINTF -DHAVE_STRCASECMP -DWin32 \ -DHAVE_LIBXML=1 -DHAVE_UNISTD_H -Wall -DHAVE_FMIN=1 -DHAVE_LOG2=1 -DHAVE_GFORTRAN \ -DINTERNAL_ARPACK -I${GLPK_HOME}/include -DHAVE_GLPK=1 -DIGRAPH_THREAD_LOCAL= \ - -DPRPACK_IGRAPH_SUPPORT -I. -Icore -Iinclude -Ivendor -DNDEBUG -DNTIMER -DNPRINT \ + -DPRPACK_IGRAPH_SUPPORT -I. -Ivendor -DNDEBUG -DNTIMER -DNPRINT \ -I${LIB_GMP}/include 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) -llzma - diff --git a/tools/stimulus/Makevars.win b/tools/stimulus/Makevars.win index c6064252844..9f4b5483664 100644 --- a/tools/stimulus/Makevars.win +++ b/tools/stimulus/Makevars.win @@ -6,7 +6,7 @@ PKG_CPPFLAGS = -I${LIB_XML}/include/libxml2 -I${LIB_XML}/include -DLIBXML_STATIC -DHAVE_FMEMOPEN=0 -DHAVE_OPEN_MEMSTREAM=0 -DHAVE_RINTF -DHAVE_STRCASECMP -DWin32 \ -DHAVE_LIBXML=1 -DHAVE_UNISTD_H -Wall -DHAVE_FMIN=1 -DHAVE_LOG2=1 -DHAVE_GFORTRAN \ -DINTERNAL_ARPACK -I${GLPK_HOME}/include -DHAVE_GLPK=1 -DIGRAPH_THREAD_LOCAL= \ - -DPRPACK_IGRAPH_SUPPORT -I. -Icore -Iinclude -Ivendor -DNDEBUG -DNTIMER -DNPRINT \ + -DPRPACK_IGRAPH_SUPPORT -I. -Ivendor -DNDEBUG -DNTIMER -DNPRINT \ -I${LIB_GMP}/include PKG_LIBS = -L${LIB_XML}/lib -lxml2 -liconv -lz -lws2_32 -lstdc++ -L${GLPK_HOME}/lib \ diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index 1d815470784..4d165460825 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -61,13 +61,13 @@ igraph_is_same_graph: # Constructors, deterministic ####################################### -igraph_create: - IGNORE: RR, RC - igraph_adjacency: - IGNORE: RR, RC, RInit + IGNORE: RR igraph_weighted_adjacency: + IGNORE: RR + +igraph_create: IGNORE: RR, RC igraph_star: @@ -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, OPTIONAL VECTOR_INT in_deg=NULL, EDGE_TYPE_SW allowed_edge_types=SIMPLE, REALIZE_DEGSEQ_METHOD method=SMALLEST R: GATTR: @@ -278,6 +278,9 @@ igraph_minimum_spanning_tree_prim: igraph_closeness: IGNORE: RR +igraph_expand_path_to_pairs: + IGNORE: RR + igraph_closeness_cutoff: IGNORE: RR @@ -289,6 +292,9 @@ igraph_get_shortest_paths: igraph_get_all_shortest_paths: IGNORE: RR + PARAM_NAMES: + vertices: vpaths + edges: epaths igraph_shortest_paths_dijkstra: IGNORE: RR, RC, RInit @@ -301,6 +307,9 @@ igraph_get_shortest_paths_bellman_ford: igraph_get_all_shortest_paths_dijkstra: IGNORE: RR + PARAM_NAMES: + vertices: vpaths + edges: epaths igraph_shortest_paths_bellman_ford: IGNORE: RR, RC, RInit @@ -341,9 +350,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 @@ -408,6 +414,38 @@ igraph_girth: igraph_add_edge: IGNORE: RR, RC, RInit +igraph_personalized_pagerank_vs: + DEPS: vids ON graph, weights ON graph, vector ON graph vids, + options ON algo, reset_vids ON graph + +igraph_get_all_eids_between: + # This is a temporary hack; we need to find a way to handle default values + # for dependencies. The problem is that the VERTEXINDEX type needs two + # dependencies: the graph and the vertex set, but we only have the graph + # in the argument list. + DEPS: from ON graph, to ON graph, eids ON graph + +igraph_hub_and_authority_scores: + DEPS: weights ON graph, hub_vector ON graph, authority_vector ON graph + +igraph_pseudo_diameter: + DEPS: start_vid ON graph + +igraph_pseudo_diameter_dijkstra: + DEPS: start_vid ON graph, weights ON graph + +igraph_bfs_simple: + DEPS: root ON graph + +igraph_is_bipartite: + DEPS: type ON graph + +igraph_bipartite_game: + DEPS: types ON graph + +igraph_vertex_path_from_edge_path: + DEPS: start ON graph, edge_path ON graph + igraph_eigenvector_centrality: # This is a temporary hack; we need to find a way to handle default values # for dependencies. The problem is that the VERTEXINDEX type needs two @@ -435,8 +473,8 @@ igraph_arpack_rssolve: igraph_arpack_rnsolve: IGNORE: RR, RC, RInit -igraph_arpack_unpack_complex: - IGNORE: RR +igraph_get_shortest_path_astar: + IGNORE: RR, RC, Rinit igraph_unfold_tree: IGNORE: RR @@ -492,12 +530,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 +547,7 @@ igraph_laplacian: # Components ####################################### -igraph_clusters: +igraph_connected_components: IGNORE: RR igraph_decompose: @@ -581,6 +613,7 @@ igraph_layout_circle: IGNORE: RR, RC igraph_layout_star: + DEPS: center ON graph IGNORE: RR igraph_layout_grid: @@ -632,6 +665,8 @@ igraph_layout_sugiyama: IGNORE: RR igraph_layout_mds: + PARAMS: |- + GRAPH graph, OUT MATRIX res, MATRIX_OR_0 dist, INTEGER dim=2 IGNORE: RR igraph_layout_bipartite: @@ -755,6 +790,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 +809,6 @@ igraph_to_undirected: igraph_get_stochastic: IGNORE: RR -igraph_get_stochastic_sparsemat: - IGNORE: RR - ####################################### # Read and write foreign formats ####################################### @@ -977,20 +1019,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 +1121,19 @@ 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 + +igraph_get_stochastic_sparsemat: + PARAMS: |- + GRAPH graph, OUT SPARSEMATPTR sparsemat, + BOOLEAN column_wise=False + +igraph_hrg_dendrogram: + PARAMS: OUT GRAPH graph, HRG hrg + +igraph_is_tree: + PARAMS: GRAPH graph, PRIMARY OUT BOOLEAN res, OPTIONAL OUT VERTEX_ROOT root, NEIMODE mode=OUT + DEPS: root ON graph ####################################### # Coloring @@ -1088,3 +1145,6 @@ igraph_random_spanning_tree: igraph_convergence_degree: IGNORE: RR, RC, RInit + +igraph_community_voronoi: + IGNORE: RR, RC, RInit diff --git a/tools/stimulus/rinterface.c.in b/tools/stimulus/rinterface.c.in index 5a6a1c89a2e..4101450aaf9 100644 --- a/tools/stimulus/rinterface.c.in +++ b/tools/stimulus/rinterface.c.in @@ -22,8 +22,8 @@ */ #include "igraph.h" -#include "graph/attributes.h" -#include "graph/neighbors.h" +#include "igraph_neighborhood.h" +#include "cigraph/src/graph/attributes.h" #include "config.h" @@ -58,25 +58,25 @@ 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_vector_int_list_to_SEXPp1(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); @@ -90,24 +90,25 @@ 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); 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_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it, igraph_vector_int_t *data); +int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it, igraph_vector_int_t *data); 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_vector_list(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_copy(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); @@ -117,11 +118,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 b42ec8a6454..5111d26135d 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -37,6 +37,21 @@ GRAPH_OR_0: IGRAPH_I_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_FREE(%C%.stor_begin); + IGRAPH_FINALLY_CLEAN(1); + INTEGER: CTYPE: igraph_integer_t CALL: @@ -44,18 +59,29 @@ INTEGER: OUT: '&%C%' INOUT: '&%C%' INCONV: - IN: '%C%=INTEGER(%I%)[0];' + IN: '%C%=(igraph_integer_t) REAL(%I%)[0];' OUT: '%C%=0;' OUTCONV: OUT: |- - PROTECT(%I%=NEW_INTEGER(1)); - INTEGER(%I%)[0]=%C%; + PROTECT(%I%=NEW_NUMERIC(1)); + REAL(%I%)[0]=(double) %C%; 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: @@ -91,8 +117,6 @@ ERROR: CTYPE: int INDEX_VECTOR: - # Indices in R are 1-based; the conversion takes place in the R layer, - # see types-RR.yaml CALL: '&%C%' CTYPE: igraph_vector_int_t INCONV: @@ -109,7 +133,36 @@ INDEX_VECTOR: igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); OUT: |- - PROTECT(%I%=R_igraph_vector_int_to_SEXP(&%C%)); + PROTECT(%I%=R_igraph_vector_int_to_SEXPp1(&%C%)); + igraph_vector_int_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + +INDEX_VECTOR_OR_0: + CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CTYPE: igraph_vector_int_t + INCONV: + IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector_int_copy(%I%, &%C%); } + INOUT: |- + if (!Rf_isNull(%I%)) { + if (0 != R_SEXP_to_vector_int_copy(%I%, &%C%)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + } else { + if (0 != igraph_vector_int_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); + %I%=NEW_NUMERIC(0); + OUT: |- + if (0 != igraph_vector_int_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); + %I%=R_GlobalEnv; /* hack to have a non-NULL value */ + OUTCONV: + OUT: |- + PROTECT(%I%=R_igraph_0orvector_int_to_SEXPp1(&%C%)); igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); @@ -138,63 +191,75 @@ VECTOR: igraph_vector_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTORM1: - CALL: '&%C%' +VECTOR_OR_0: + CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' CTYPE: igraph_vector_t INCONV: - IN: R_SEXP_to_vector(%I%, &%C%); + IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector(%I%, &%C%); } INOUT: |- - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + if (!Rf_isNull(%I%)) { + if (0 != R_SEXP_to_vector(%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_vector_to_SEXPp1(&%C%)); + PROTECT(%I%=R_igraph_0orvector_to_SEXP(&%C%)); igraph_vector_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTOR_BOOL: +VECTORM1: CALL: '&%C%' - CTYPE: igraph_vector_bool_t + CTYPE: igraph_vector_int_t INCONV: - IN: R_SEXP_to_vector_bool(%I%, &%C%); + IN: R_SEXP_to_vector_int_copy(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_vector_bool_copy(%I%, &%C%)) { + if (0 != R_SEXP_to_vector_int_copy(%I%, &%C%)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_bool_init(&%C%, 0)) { + if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_vector_bool_to_SEXP(&%C%)); - igraph_vector_bool_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_int_to_SEXPp1(&%C%)); + igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTOR_LONG: +VECTOR_BOOL: CALL: '&%C%' - CTYPE: igraph_vector_long_t + CTYPE: igraph_vector_bool_t INCONV: - IN: R_SEXP_to_vector_long_copy(%I%, &%C%); + IN: R_SEXP_to_vector_bool(%I%, &%C%); + INOUT: |- + if (0 != R_SEXP_to_vector_bool_copy(%I%, &%C%)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); OUT: |- - if (0 != igraph_vector_long_init(&%C%, 0)) { + if (0 != igraph_vector_bool_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_long_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); OUTCONV: - IN: igraph_vector_long_destroy(&%C%); OUT: |- - PROTECT(%I%=R_igraph_vector_long_to_SEXP(&%C%)); - igraph_vector_long_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_bool_to_SEXP(&%C%)); + igraph_vector_bool_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); VECTOR_INT: @@ -218,147 +283,144 @@ VECTOR_INT: igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTOR_LONG_M1: +MATRIX_LIST: CALL: '&%C%' - CTYPE: igraph_vector_long_t + CTYPE: igraph_matrix_list_t INCONV: - IN: R_SEXP_to_vector_long_copy(%I%, &%C%); + IN: R_igraph_SEXP_to_matrixlist(%I%, &%C%); + +VECTOR_LIST: + CALL: '&%C%' + CTYPE: igraph_vector_list_t + INCONV: + IN: R_igraph_SEXP_to_vector_list(%I%, &%C%); OUT: |- - if (0 != igraph_vector_long_init(&%C%, 0)) { + if (0 != igraph_vector_list_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_long_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_list_destroy, &%C%); OUTCONV: - IN: igraph_vector_long_destroy(&%C%); OUT: |- - PROTECT(%I%=R_igraph_vector_long_to_SEXPp1(&%C%)); - igraph_vector_long_destroy(&%C%); + PROTECT(%I%=R_igraph_vectorlist_to_SEXP(&%C%)); + igraph_vector_list_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTORLIST: +VECTOR_INT_LIST: CALL: '&%C%' - CTYPE: igraph_vector_ptr_t + CTYPE: igraph_vector_int_list_t INCONV: - IN: 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(&%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); -MATRIXLIST: +VERTEXSET_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: |- + R_igraph_SEXP_to_vector_int_list(%I%, &%C%); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%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: + IN: |- + igraph_vector_int_list_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); OUT: |- - PROTECT(%I%=R_igraph_vectorlist_to_SEXP_p1(&%C%)); - R_igraph_vectorlist_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_int_list_to_SEXPp1(&%C%)); + igraph_vector_int_list_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VERTEXSETLIST_INT: +EDGESET_LIST: CALL: '&%C%' - CTYPE: igraph_vector_ptr_t - INCONV: - IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vectorlist_int(%I%, &%C%); } - -EDGESETLIST: - 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_SEXPp1(&%C%)); + igraph_vector_int_list_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -ADJLIST: - CALL: '&%C%' - CTYPE: igraph_adjlist_t +EDGE_SELECTOR: + CALL: + IN: '%C%' + OUT: '&%C%' + CTYPE: + IN: igraph_es_t + OUT: igraph_vector_t INCONV: IN: |- - if (0 != R_SEXP_to_igraph_adjlist(%I%, &%C%)) { - 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); + igraph_vector_int_t %C%_data; + R_SEXP_to_igraph_es(%I%, &%C1%, &%C%, &%C%_data); 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: + IN: |- + igraph_vector_int_destroy(&%C%_data); + igraph_es_destroy(&%C%); OUT: |- - PROTECT(%I%=R_igraph_0orvector_to_SEXP(&%C%)); + PROTECT(%I%=R_igraph_vector_to_SEXPp1(&%C%)); igraph_vector_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTORM1_OR_0: +ADJLIST: + CALL: '&%C%' + CTYPE: igraph_adjlist_t + INCONV: + IN: |- + if (0 != R_SEXP_to_igraph_adjlist(%I%, &%C%)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + OUTCONV: + IN: igraph_adjlist_destroy(&%C%); + +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_copy(%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: @@ -395,7 +457,7 @@ VERTEXWEIGHTS: igraph_vector_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -EDGECAPACITY: +EDGE_CAPACITY: CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' CTYPE: igraph_vector_t INCONV: @@ -479,6 +541,32 @@ MATRIX_OR_0: igraph_matrix_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); +MATRIX_INT: + CALL: '&%C%' + CTYPE: igraph_matrix_int_t + INCONV: + IN: |- + R_SEXP_to_matrix_int(%I%, &%C%); + IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); + INOUT: |- + if (0 != R_SEXP_to_igraph_matrix_int_copy(%I%, &%C%)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); + OUT: |- + if (0 != igraph_matrix_int_init(&%C%, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); + OUTCONV: + IN: |- + igraph_matrix_int_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + OUT: |- + PROTECT(%I%=R_igraph_matrix_int_to_SEXP(&%C%)); + igraph_matrix_int_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + ARRAY3: CALL: '&%C%' CTYPE: igraph_array3_t @@ -527,7 +615,43 @@ VERTEX: PROTECT(%I% = NEW_INTEGER(1)); INTEGER(%I%)[0] = %C% + 1; -VERTEXSET: +VERTEX_ROOT: + CALL: + IN: '%C%' + INOUT: '&%C%' + OUT: '&%C%' + CTYPE: igraph_integer_t + INCONV: + IN: '%C% = (igraph_integer_t) REAL(%I%)[0];' + INOUT: '%C% = (igraph_integer_t) REAL(%I%)[0];' + OUT: '%C% = -1;' + OUTCONV: + OUT: |- + 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); + +VERTEX_SELECTOR: CALL: IN: '%C%' OUT: '&%C%' @@ -535,27 +659,28 @@ VERTEXSET: IN: igraph_vs_t OUT: igraph_vector_t INCONV: - IN: R_SEXP_to_igraph_vs(%I%, &%C1%, &%C%); + IN: |- + igraph_vector_int_t %C%_data; + R_SEXP_to_igraph_vs(%I%, &%C1%, &%C%, &%C%_data); OUT: |- if (0 != igraph_vector_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUTCONV: - IN: igraph_vs_destroy(&%C%); + IN: |- + igraph_vector_int_destroy(&%C%_data); + igraph_vs_destroy(&%C%); OUT: |- PROTECT(%I%=R_igraph_vector_to_SEXPp1(&%C%)); 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_copy(%I%, &%C%); OUT: |- if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); @@ -567,25 +692,36 @@ VERTEXSET_INT: 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_copy(%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_copy(%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_SEXPp1(&%C%)); + igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); 'NULL': @@ -603,6 +739,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: @@ -615,6 +766,11 @@ ARPACKSTORAGE: CTYPE: ~ HEADER: {} +ARPACKFUNC: + CALL: '0' + CTYPE: ~ + HEADER: {} + DRL_OPTIONS: CALL: '&%C%' INCONV: @@ -627,7 +783,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: @@ -870,21 +1026,6 @@ MATRIX_COMPLEX: igraph_matrix_complex_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VERTEXINDEX: - CALL: '&%C%' - CTYPE: igraph_vector_t - INCONV: - 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); - PLFIT: CALL: '&%C%' OUTCONV: @@ -909,7 +1050,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 e09ef675833..5514cd52649 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -9,7 +9,7 @@ INTEGER: DEFAULT: FINEITER: max(10, log2(vcount(graph))) INCONV: - IN: '%I% <- as.integer(%I%)' + IN: '%I% <- as.numeric(%I%)' REAL: DEFAULT: @@ -28,15 +28,17 @@ BOOLEAN: INDEX_VECTOR: # Indices in R are 1-based; the conversion takes place here - INCONV: '%I% <- as.integer(%I%)-1L' - OUTCONV: '%I% <- %I%+1' + INCONV: '%I% <- as.numeric(%I%)-1L' + +INDEX_VECTOR_OR_0: + INCONV: 'if (!is.null(%I%)) %I% <- as.numeric(%I%)-1L' VECTOR: DEFAULT: AsmDefaultCvec: strength(%I1%, weights=weights)/(vcount(%I1%)-1) INCONV: '%I% <- as.numeric(%I%)' -VERTEXINDEX: +VERTEX_QTY: OUTCONV: OUT: |- if (igraph_opt("add.vertex.names") && is_named(%I1%)) { @@ -47,7 +49,10 @@ VECTOR_LONG: INCONV: '%I% <- as.numeric(%I%)' VECTOR_INT: - INCONV: '%I% <- as.integer(%I%)' + INCONV: '%I% <- as.numeric(%I%)' + +VECTOR_INT_OR_0: + INCONV: if (!is.null(%I%)) %I% <- as.numeric(%I%) VECTORM1: INCONV: '%I% <- as.numeric(%I%)-1' @@ -92,7 +97,7 @@ NEIMODE: IN: c("in", "out", "all", "total") OUT: c("out", "in", "all", "total") TOTAL: c("total", "out", "in", "all") - INCONV: '%I% <- switch(igraph.match.arg(%I%), "out"=1, "in"=2, "all"=3, "total"=3)' + INCONV: '%I% <- switch(igraph.match.arg(%I%), "out"=1L, "in"=2L, "all"=3L, "total"=3L)' TODIRECTED: DEFAULT: @@ -125,7 +130,20 @@ VERTEX: %I% <- create_vs(%I1%, %I%) } -VERTEXSET: +VERTEX_ROOT: + CALL: '%I%-1' + INCONV: |- + %I% <- as_igraph_vs(%I1%, %I%) + if (length(%I%) == 0) { + stop("No vertex was specified") + } + OUTCONV: + OUT: |- + if (igraph_opt("return.vs.es") && vcount(%I1%) != 0) { + %I% <- create_vs(%I1%, %I%) + } + +VERTEX_SELECTOR: CALL: '%I%-1' DEFAULT: ALL: V(%I1%) @@ -136,7 +154,7 @@ VERTEXSET: %I% <- create_vs(%I1%, %I%) } -VERTEXSET_INT: +VERTEX_INDICES: CALL: '%I%-1' DEFAULT: ALL: V(%I1%) @@ -147,7 +165,18 @@ VERTEXSET_INT: %I% <- create_vs(%I1%, %I%) } -EDGESET: +EDGE_INDICES: + CALL: '%I%-1' + DEFAULT: + ALL: E(%I1%) + INCONV: '%I% <- as_igraph_es(%I1%, %I%)' + OUTCONV: + OUT: |- + if (igraph_opt("return.vs.es")) { + %I% <- create_es(%I1%, %I%) + } + +EDGE_SELECTOR: CALL: '%I%-1' DEFAULT: ALL: E(%I1%) @@ -180,7 +209,7 @@ VERTEXWEIGHTS: %I% <- NULL } -EDGECAPACITY: +EDGE_CAPACITY: INCONV: |- if (is.null(%I%) && "capacity" %in% edge_attr_names(%I1%)) { %I% <- E(%I1%)$capacity @@ -210,7 +239,7 @@ VERTEX_COLOR: } } if (!is.null(%I%)) { - %I% <- as.integer(%I%)-1L + %I% <- as.numeric(%I%)-1L } OUTCONV: OUT: |- @@ -256,7 +285,7 @@ MATRIXLIST: stop("%I% is not a list of matrices") } -VERTEXSETLIST: +VERTEXSET_LIST: OUTCONV: OUT: |- if (igraph_opt("return.vs.es")) { @@ -270,7 +299,7 @@ VERTEXSETLIST_INT: INCONV: IN: '%I% <- lapply(%I%, function(x) as.integer(x)-1L)' -EDGESETLIST: +EDGESET_LIST: OUTCONV: OUT: |- if (igraph_opt("return.vs.es")) { @@ -307,7 +336,7 @@ BLISSSH: BLISSINFO: {} ADJLIST: - INCONV: '%I% <- lapply(%I%, function(x) as.integer(x)-1L)' + INCONV: '%I% <- lapply(%I%, function(x) as.double(x)-1L)' COMMCMP: DEFAULT: @@ -370,12 +399,12 @@ SCGDIR: INCONV: '%I% <- switch(igraph.match.arg(%I%), "default"=1, "left"=2, "right"=3)' SPARSEMAT: - INCONV: require(Matrix); %I% <- as(as(as(%I%, "dMatrix"), "generalMatrix"), "CsparseMatrix") + INCONV: requireNamespace("Matrix", quietly = TRUE); %I% <- as(as(as(%I%, "dMatrix"), "generalMatrix"), "CsparseMatrix") SPARSEMAT_OR_0: INCONV: |- if (!is.null(%I%)) { - require(Matrix); %I% <- as(as(as(%I%, "dMatrix"), "generalMatrix"), "CsparseMatrix") + requireNamespace("Matrix", quietly = TRUE); %I% <- as(as(as(%I%, "dMatrix"), "generalMatrix"), "CsparseMatrix") } VECTOR_COMPLEX: @@ -386,6 +415,8 @@ MATRIX_COMPLEX: PLFIT: {} +SPARSEMATPTR: {} + MAXFLOW_STATS: CALL: {} HEADER: ~ @@ -468,9 +499,9 @@ RANDOM_TREE_METHOD: GREEDY_COLORING_HEURISTIC: DEFAULT: - NEIGHBORS: c("colored_neighbors") + NEIGHBORS: c("colored_neighbors", "dsatur") INCONV: |- - %I% <- switch(igraph.match.arg(%I%), "colored_neighbors"=0L) + %I% <- switch(igraph.match.arg(%I%), "colored_neighbors"=0L, "dsatur"=1L) REALIZE_DEGSEQ_METHOD: DEFAULT: diff --git a/tools/update-cigraph.sh b/tools/update-cigraph.sh index 5d57798124a..8b99dc92fe8 100755 --- a/tools/update-cigraph.sh +++ b/tools/update-cigraph.sh @@ -1,14 +1,12 @@ #! /bin/sh -set -euo pipefail - cd $(dirname $0)/.. rm -rf src/vendor/cigraph mkdir -p src/vendor -git clone https://github.com/igraph/igraph src/vendor/cigraph +git clone https://github.com/igraph/igraph --depth=1 src/vendor/cigraph if [ -n "${1-}" ]; then git -C src/vendor/cigraph switch --detach "$1" @@ -18,6 +16,6 @@ version=$(git -C src/vendor/cigraph rev-parse HEAD) rm -rf src/vendor/cigraph/.git -rm -rf src/vendor/cigraph/{.github,doc,examples,fuzzing,tests,tools} +rm -rf src/vendor/cigraph/.github src/vendor/cigraph/doc src/vendor/cigraph/examples src/vendor/cigraph/fuzzing src/vendor/cigraph/tests src/vendor/cigraph/tools git add src/vendor/cigraph git commit -m "Update vendored igraph/C to igraph/igraph@${version}"