Skip to content

Commit

Permalink
test igraph behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Dec 3, 2024
1 parent 555e37b commit 4832488
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
29 changes: 20 additions & 9 deletions R/igraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,29 @@ drake_adjacent_vertices <- function(graph, v, mode) {
index <- adjacent_vertices(graph = graph, v = v, mode = mode)
index <- unlist(index, use.names = FALSE)
index <- unique(index)
if (is.null(igraph_version_offset$offset)) {
igraph_version_offset$offset <- as.integer(
utils::compareVersion(
a = as.character(packageVersion("igraph")),
b = "2.1.2"
) < 0L
)
igraph::V(graph)$name[index + get_igraph_offset()]
}

get_igraph_offset <- function() {
if (!is.null(igraph_offset$offset)) {
return(igraph_offset$offset)
}
igraph::V(graph)$name[index + igraph_version_offset$offset]
opt <- igraph::igraph_opt("return.vs.es")
on.exit(igraph::igraph_options(return.vs.es = opt))
igraph::igraph_options(return.vs.es = FALSE)
test_graph <- igraph::make_graph(edges = c("a", "b"))
adjacent <- igraph::adjacent_vertices(
graph = test_graph,
v = "a",
mode = "out"
)
adjacent <- as.integer(adjacent)
offset <- 2L - adjacent
igraph_offset$offset <- offset
offset
}

igraph_version_offset <- new.env(parent = emptyenv())
igraph_offset <- new.env(parent = emptyenv())

subset_graph <- function(graph, subset) {
if (!length(subset)) {
Expand Down
7 changes: 2 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ Development
<td align="left">
<a href="https://github.com/ropensci/software-review/issues/156"><img src="https://badges.ropensci.org/156_status.svg" alt="rOpenSci"></a>
</td>
<td align="left">
<a href="https://codecov.io/github/ropensci/drake?branch=main"><img src="https://codecov.io/github/ropensci/drake/coverage.svg?branch=main" alt="Codecov"></a>
</td>
</tr>
<tr class="even">
<td align="left">
Expand Down Expand Up @@ -361,7 +358,7 @@ make(plan, parallelism = "clustermq", jobs = 4)
- [`drake-gitlab-docker-example`](https://gitlab.com/ecohealthalliance/drake-gitlab-docker-example): A small pedagogical example workflow that leverages `drake`, Docker, GitLab, and continuous integration in a reproducible analysis pipeline. Created by [Noam Ross](https://www.noamross.net/).
- [`pleurosoriopsis`](https://github.com/joelnitta/pleurosoriopsis): The workflow that supports [Ebihara *et al.* 2019. "Growth Dynamics of the Independent Gametophytes of *Pleurorosiopsis makinoi* (Polypodiaceae)" *Bulletin of the National Science Museum Series B (Botany)* 45:77-86.](https://www.kahaku.go.jp/research/publication/botany.html). Created by [Joel Nitta](https://github.com/joelnitta).

Alternatively, it is possible to run `drake` outside Docker and use the [`future`](https://github.com/HenrikBengtsson/future) package to send targets to a Docker image. `drake`'s [`Docker-psock`](https://github.com/wlandau/drake-examples/tree/main/Docker-psock) example demonstrates how. Download the code with `drake_example("Docker-psock")`.
Alternatively, it is possible to run `drake` outside Docker and use the [`future`](https://github.com/futureverse/future) package to send targets to a Docker image. `drake`'s [`Docker-psock`](https://github.com/wlandau/drake-examples/tree/main/Docker-psock) example demonstrates how. Download the code with `drake_example("Docker-psock")`.

# Installation

Expand Down Expand Up @@ -534,7 +531,7 @@ Many thanks to [Julia Lowndes](https://github.com/jules32), [Ben Marwick](https:
- [Eric Nantz](https://github.com/rpodcast)
- [Henrik Bengtsson](https://github.com/HenrikBengtsson)
- [Ian Watson](https://github.com/IanAWatson)
- [Jasper Clarkberg](https://github.com/dapperjapper)
- Jasper Clarkberg
- [Kendon Bell](https://github.com/kendonB)
- [Kirill M&uuml;ller](https://github.com/krlmlr)
- [Michael Schubert](https://github.com/mschubert)
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ Development
<td align="left">
<a href="https://github.com/ropensci/software-review/issues/156"><img src="https://badges.ropensci.org/156_status.svg" alt="rOpenSci"></a>
</td>
<td align="left">
<a href="https://codecov.io/github/ropensci/drake?branch=main"><img src="https://codecov.io/github/ropensci/drake/coverage.svg?branch=main" alt="Codecov"></a>
</td>
</tr>
<tr class="even">
<td align="left">
Expand Down Expand Up @@ -492,7 +489,7 @@ examples that run `drake` inside a Docker image.
Created by [Joel Nitta](https://github.com/joelnitta).

Alternatively, it is possible to run `drake` outside Docker and use the
[`future`](https://github.com/HenrikBengtsson/future) package to send
[`future`](https://github.com/futureverse/future) package to send
targets to a Docker image. `drake`’s
[`Docker-psock`](https://github.com/wlandau/drake-examples/tree/main/Docker-psock)
example demonstrates how. Download the code with
Expand Down Expand Up @@ -864,7 +861,7 @@ early in development.
- [Eric Nantz](https://github.com/rpodcast)
- [Henrik Bengtsson](https://github.com/HenrikBengtsson)
- [Ian Watson](https://github.com/IanAWatson)
- [Jasper Clarkberg](https://github.com/dapperjapper)
- Jasper Clarkberg
- [Kendon Bell](https://github.com/kendonB)
- [Kirill Müller](https://github.com/krlmlr)
- [Michael Schubert](https://github.com/mschubert)
Expand Down

0 comments on commit 4832488

Please sign in to comment.