dag.sp {RBGL} | R Documentation

## DAG shortest paths using boost C++

### Description

Algorithm for the single-source shortest-paths problem on a weighted, directed acyclic graph (DAG)

### Usage

    dag.sp(g,start=nodes(g)[1])

### Arguments

`g` | instance of class graph
`start` | source node for start of paths

### Details

These functions are interfaces to the Boost graph library C++ routines for single-source shortest-paths on a weighted directed acyclic graph. Choose appropriate shortest-path algorithms carefully based on the properties of the input graph. See documentation in Boost Graph Library for more details.

### Value

A list with elements:

`distance` | The vector of distances from `start` to each node of `g`; includes `Inf` when there is no path from `start`.
`penult` | A vector of indices (in `nodes(g)`) of predecessors corresponding to each node on the path from that node back to `start`. For example, if the element one of this vector has value `10`, that means that the predecessor of node `1` is node `10`. The next predecessor is found by examining `penult[10]`.
`start` | The start node that was supplied in the call to `dag.sp`.

### Author(s)

Li Long <li.long@isb-sib.ch>

### See Also

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

### Examples

    dd <- fromGXL(file(system.file("XML/conn2.gxl",package="RBGL"), open="r"))
    dag.sp(dd)
    dag.sp(dd,nodes(dd)[2])

[Package RBGL version 1.10.0 Index]