View source: R/shortest_path_igraph.R
shortest_path_igraph | R Documentation |
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.
shortest_path_igraph( from_node_ID, to_node_ID, graph_object = graph, unit = "minutes", path = FALSE )
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 |
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.
Vector with the shortest path in minutes or meters. If path = TRUE
the node link that the shortest path consists of is returned.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.