Skip to content

Commit

Permalink
igraph dfs may signal unreachable nodes with 0
Browse files Browse the repository at this point in the history
* this still seems to be up in the air but at least some preparatory branches
 for igraph 2.0 use a 0 rather than NaN to signal unreachable nodes
* see #517
  • Loading branch information
jefferis committed Jan 20, 2024
1 parent 735628d commit c1aacf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/neuron.R
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,8 @@ distal_to <- function(x, node.idx=NULL, node.pointno=NULL, root.idx=NULL,

dfs_traversal <- function(x, g) {
gdfs=igraph::dfs(g, root = x, unreachable = FALSE)
as.integer(gdfs$order)[!is.na(gdfs$order)]
# nb igraph 2.0 may change signalling for unreached nodes
as.integer(gdfs$order)[!(is.na(gdfs$order) | gdfs$order<1)]
}


Expand Down
2 changes: 2 additions & 0 deletions R/ngraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ prune_vertices<-function(x, verticestoprune, invert=FALSE, ...) {
if(invert) {
nvertices=igraph::vcount(g)
verticestoprune=setdiff(seq_len(nvertices), verticestoprune)
} else {
verticestoprune=setdiff(verticestoprune, 0)
}
dg=igraph::delete_vertices(g, verticestoprune)
# delete_vertices will return an igraph
Expand Down

0 comments on commit c1aacf8

Please sign in to comment.