Thanks, this is a known bug, it was fixed in our development tree. Here is
a workaround function:
get.shortest.paths <- function(graph, from, to=V(graph),
mode=c("out", "all", "in"),
weights=NULL,
output=c("vpath", "epath", "both")) {
if (!is.igraph(graph)) {
stop("Not a graph object")
}
mode <- igraph:::igraph.match.arg(mode)
mode <- switch(mode, "out"=1, "in"=2, "all"=3)
ooutput <- igraph:::igraph.match.arg(output)
output <- switch(ooutput, "vpath"=0, "epath"=2, "both"=2)
if (is.null(weights)) {
if ("weight" %in% list.edge.attributes(graph)) {
weights <- as.numeric(E(graph)$weight)
}
} else {
if (length(weights)==1 && is.na(weights)) {
weights <- NULL
} else {
weights <- as.numeric(weights)
}
}
to <- igraph:::as.igraph.vs(graph, to)-1
on.exit( .Call("R_igraph_finalizer", PACKAGE="igraph") )
res <- .Call("R_igraph_get_shortest_paths", graph,
igraph:::as.igraph.vs(graph, from)-1, to, as.numeric(mode),
as.numeric(length(to)),
weights, as.numeric(output), PACKAGE="igraph")
if (output !=2 ) {
res <- lapply(res, function(x) x+1)
} else {
res <- list(vpath=lapply(res$vpath, function(x) x+1),
epath=lapply(res$epath, function(x) x+1))
}
if (ooutput == "epath") { res$epath } else { res }
}
Thanks, Best,
Gabor
On Wed, Jan 23, 2013 at 3:45 AM, David Edwards <[email protected]>wrote:
> I cant get get.shortest.paths() to work when I set output=”epath”: ****
>
> ** **
>
> g <- graph.tree(25, children = 2, mode="out")****
>
> get.shortest.paths(g, 1, output="vpath") # works ok****
>
> get.shortest.paths(g, 1, output="epath") # gives error****
>
> ** **
>
> ** **
>
> Best regards****
>
> David****
>
> ** **
>
> _______________________________________________
> igraph-help mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
--
Gabor Csardi <[email protected]> MTA KFKI RMKI
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help