shortest path outputs not properly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
igraph |
Invalid
|
High
|
Gábor Csárdi |
Bug Description
Hi,
sp function outputs paths of node 3 - 1- 7 with weight of 16
but
path 3 - 4 - 7 has only weight of 5
is there any problem in my code ?
-------
library(igraph)
#edge list
d <- data.frame(
colnames(d) <- c("from","to")
#node list
vers <- data.frame(
#create graph
g <- graph.data.
#weight
w1 <- c(3, 1, 8, 6, 2, 7, 8, 3, 3, 3, 7, 8, 1, 4, 3, 3, 1, 4, 8, 3, 1, 8, 6, 2, 7, 8, 3, 3, 3, 7, 8, 1, 4, 3, 3, 1, 4, 8)
E(g)$weight <- w1
#shortest path
sp <- get.shortest.
sp
c(c(d[[1]][7], d[[2]][
E(g)$weight[
c(c(d[[1]][10], d[[2]][
E(g)$weight[
You should use mode="out" if you want a directed path.
> get.shortest. paths(g, from=3, to=7, mode="out")
[[1]]
[1] 3 4 7
I agree that
- this is confusing
- it should be the default
- it should work properly, even if one uses mode="all"
So this is a bug.