get.shortest.paths {igraph} | R Documentation |
Shortest (directed or undirected) paths between vertices
Description
get.shortest.paths()
was renamed to shortest_paths()
to create a more
consistent API.
Usage
get.shortest.paths(
graph,
from,
to = V(graph),
mode = c("out", "all", "in"),
weights = NULL,
output = c("vpath", "epath", "both"),
predecessors = FALSE,
inbound.edges = FALSE,
algorithm = c("automatic", "unweighted", "dijkstra", "bellman-ford")
)
Arguments
graph |
The graph to work on. |
from |
Numeric constant, the vertex from or to the shortest paths will be calculated. Note that right now this is not a vector of vertex ids, but only a single vertex. |
to |
Numeric vector, the vertices to which the shortest paths will be
calculated. By default it includes all vertices. Note that for
|
mode |
Character constant, gives whether the shortest paths to or from
the given vertices should be calculated for directed graphs. If |
weights |
Possibly a numeric vector giving edge weights. If this is
|
output |
Character scalar, defines how to report the shortest paths. “vpath” means that the vertices along the paths are reported, this form was used prior to igraph version 0.6. “epath” means that the edges along the paths are reported. “both” means that both forms are returned, in a named list with components “vpath” and “epath”. |
predecessors |
Logical scalar, whether to return the predecessor vertex
for each vertex. The predecessor of vertex |
inbound.edges |
Logical scalar, whether to return the inbound edge for
each vertex. The inbound edge of vertex |
algorithm |
Which algorithm to use for the calculation. By default igraph tries to select the fastest suitable algorithm. If there are no weights, then an unweighted breadth-first search is used, otherwise if all weights are positive, then Dijkstra's algorithm is used. If there are negative weights and we do the calculation for more than 100 sources, then Johnson's algorithm is used. Otherwise the Bellman-Ford algorithm is used. You can override igraph's choice by explicitly giving this parameter. Note that the igraph C core might still override your choice in obvious cases, i.e. if there are no edge weights, then the unweighted algorithm will be used, regardless of this argument. |