Skip to content

Commit 3809e74

Browse files
authored
Update get_path_pair.R
1 parent 7e8a675 commit 3809e74

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

R/get_path_pair.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ get_path_pair<-function(Graph,from,to,algorithm="Dijkstra",constant=1){
2020

2121
if (any(is.na(cbind(from,to)))) stop("NAs are not allowed in origin/destination nodes")
2222
from<-as.character(from)
23-
from_id<-Graph$dict$id[match(from,Graph$dict$ref)]
2423
to<-as.character(to)
24+
allnodes<-c(from,to)
25+
if (sum(allnodes %in% Graph$dict$ref)<length(allnodes)) stop("Some nodes are not in the graph")
26+
from_id<-Graph$dict$id[match(from,Graph$dict$ref)]
2527
to_id<-Graph$dict$id[match(to,Graph$dict$ref)]
2628

2729

0 commit comments

Comments
 (0)