luukvdmeer / sfnetworks

Tidy Geospatial Networks in R
https://luukvdmeer.github.io/sfnetworks/
Other
338 stars 20 forks source link

Include `direction` as an argument to `st_network_cost()` #196

Closed loreabad6 closed 2 years ago

loreabad6 commented 2 years ago

Is your feature request related to a problem? Please describe. Currently st_network_cost() has the default behavior, inherited from igraph::distances() of calculating costs by traveling each edge in both directions, i.e. an undirected network, even if the input network is directed.

Describe the solution you'd like That st_network_cost() includes the mode argument, and that its default value is set to mode="both" for undirected networks, and mode="out" for directed networks (considering only outbound edges, can be changed to mode="in" to consider only inbound edges), with its corresponding documentation.

luukvdmeer commented 2 years ago

I dont think we have to set its default conditionally, since this argument is either way ignored when the input network is undirected. See https://igraph.org/r/html/latest/distances.html So the default can just be "out", and mention in the parameter description that this parameter is ignored when the network is undirected.

Robinlovelace commented 2 years ago

Minor comment on this: the word mode in a transport context often means 'mode of transport'.

luukvdmeer commented 2 years ago

I agree that is confusing. We could use another name, e.g. direction = "in"/"out"/"all". Since ... is forwarded to igraph we should maybe give a warning that when "mode" is included in ... it is ignored and the user should set the "direction" argument instead.

luukvdmeer commented 2 years ago

Implemented in v0.6.0, see https://luukvdmeer.github.io/sfnetworks/articles/sfn04_routing.html#retrieving-an-od-cost-matrix