spath.lengths {streamDAG} | R Documentation |
Shortest path lengths and number of paths
Description
The function spath.lengths
calculates path lengths from all possible nodes to or from a designated node, i.e., the shortest in-paths and out-paths repsectively. Weighted path length are possible, including weighted path lengths based on field-observed instream arc lengths (see Examples). This results in "actual" path lengths in observed units. The function n.tot.paths
calculates the total number of paths beginning or ending at all nodes in a graph, based on exponention of the the adjacency matrix.
Usage
spath.lengths(G, node = NULL, mode = "in", ignore.inf = TRUE)
n.tot.paths(G, mode = "in", sink = NULL)
Arguments
G |
Graph of class "igraph". See |
node |
Designated node. |
mode |
One of |
ignore.inf |
Logical. Whether infinite distances are to be ignored. By default |
sink |
Name of sink node. |
Value
Lengths of paths to a node of interest.
Author(s)
Ken Aho , Gabor Csardi wrote distances
Examples
data(mur_lengths)
mur <- streamDAGs("mur_full")
n.tot.paths(mur)
spath.lengths(mur, "M1653")
E(mur)$weight <- mur_lengths[,2] # weighted (actual in-stream lengths in meters)
spath.lengths(mur, "M1653")