shortest_path_igraph {GISSB} | R Documentation |
Shortest path (igraph)
Description
The function shortest_path_igraph
can be used to calculate the shortest path (either in minutes or meters) between nodes in the Norwegian road network. The function can also return the node link, i.e. path, that the shortest path consists of.
Usage
shortest_path_igraph(
from_node_ID,
to_node_ID,
graph_object = graph,
unit = "minutes",
path = FALSE
)
Arguments
from_node_ID |
Numeric value with the from node ID (if multiple node ID’s are to be used, see the function |
to_node_ID |
Numeric value with the to node ID (if multiple node ID’s are to be used, see the function |
graph_object |
The road network structured as a tidy graph ( |
unit |
Character vector with |
path |
Logical. If |
Details
Before the function can be used, the road network must be converted to a tbl_graph
object. This can be done with the function vegnett_to_R()
). There objects graph
and edges
needs to be loaded.
Value
Vector with the shortest path in minutes or meters. If path = TRUE
the node link that the shortest path consists of is returned.
Examples
shortest_path_igraph(from_node_ID = 25,
to_node_ID = 33,
unit = "minutes",
graph_object = graph_sampledata)
shortest_path_igraph(from_node_ID = 25,
to_node_ID = 33,
unit = "meters",
graph_object = graph_sampledata)
shortest_path_igraph(from_node_ID = 25,
to_node_ID = 33,
unit = "minutes",
path = TRUE,
graph_object = graph_sampledata)