sp.between {RBGL} | R Documentation

## Dijkstra's shortest paths using boost C++

### Description

dijkstra's shortest paths

### Usage

    sp.between.scalar(g,start,finish, eW=unlist(edgeWeights(g)))
    sp.between(g,start,finish)
    sp.between.old(g,start,finish)

### Arguments

`g` | instance of class graph
`start` | character: node name(s) for start of path
`finish` | character vector: node names for end of path
`eW` | numeric: edge weights.

### Details

These functions are interfaces to the Boost graph library C++ routines for Dijkstra's shortest paths.

### Value

`sp.between.scalar` returns a list with elements:

`length` | length (using edge weights) of shortest path
`path` | vector of node names describing the path
`pweights` | named vector of edge weights for all weights constituting the path – see `pathWeights` for caveats about undirected graph representation.

Note that if `start` or `finish` are vectors, a list of results of repeated application of `sp.between.scalar` is returned.

### Note

sp.between returns a list whose size depends upon the start and finish arguments. If start and finish are both scalar, then a list is returned with elements the length of the shortest path and the vector of nodes comprising that path. If one of start or finish is an n-vector, n>1, and the other is an atom, a list is returned with n elements, each element of which is a list possessing a length and path element. If both start and finish are n-vectors, a list of n elements is returned, with ith element the distance and path between start[i] and finish[i]. It is an error to have start and finish of different nonunity lengths.

sp.between.old is included for archival purposes.

### Author(s)

VJ Carey <stvjc@channing.harvard.edu>

### See Also

`bellman.ford.sp`, `dag.sp`, `dijkstra.sp`, `johnson.all.pairs.sp`

### Examples

    ospf <- fromGXL(file(system.file("XML/ospf.gxl",package="RBGL"), open="r"))
    dijkstra.sp(ospf,nodes(ospf)[6])
    sp.between(ospf, "RT6", "RT1")
    sp.between(ospf, c("RT6", "RT2"), "RT1")
    sp.between(ospf, c("RT6", "RT2"), c("RT1","RT5"))
    if (interactive()) # see an error for query on nonexistent path
    sp.between(ospf,"N10", "N13")

[Package RBGL version 1.10.0 Index]