Description Usage Arguments Details Value Author(s) See Also Examples
dijkstra's shortest paths
1 | sp.between(g,start,finish, detail=TRUE)
|
g |
instance of class graph |
start |
node name(s) for start of path(s) |
finish |
node name(s) for end of path(s) |
detail |
if TRUE, output additional info on the shortest path |
These functions are interfaces to the Boost graph library C++ routines for Dijkstra's shortest paths.
Function sp.between.scalar
is obsolete.
When start
and/or finish
are vectors, we use the normal cycling
rule in R to match both vectors and try to find the shortest path for each
pair.
Function sp.between
returns a list of info on the shortest paths. Each
such shortest path is designated by its starting node and its ending node.
Each element in the returned list contains:
length |
total length (using edge weights) of this shortest path |
,
path_detail |
if requested, a vector of names of the nodes on the shortest path |
,
length_detail |
if requested, a list of edge weights of this shortest path |
.
See pathWeights
for caveats about undirected graph representation.
VJ Carey <stvjc@channing.harvard.edu>, Li Long <li.long@isb-sib.ch>
bellman.ford.sp
, dag.sp
, dijkstra.sp
, johnson.all.pairs.sp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | con <- file(system.file("XML/ospf.gxl",package="RBGL"), open="r")
ospf <- fromGXL(con)
close(con)
dijkstra.sp(ospf,nodes(ospf)[6])
sp.between(ospf, "RT6", "RT1")
sp.between(ospf, c("RT6", "RT2"), "RT1", detail=FALSE)
sp.between(ospf, c("RT6", "RT2"), c("RT1","RT5"))
# see NAs for query on nonexistent path
sp.between(ospf,"N10", "N13")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.