luukvdmeer / sfnetworks

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

Function to calculate the circuity of an edge #51

Closed luukvdmeer closed 4 years ago

luukvdmeer commented 4 years ago

Is your feature request related to a problem? Please describe. There are graph measures so specific to spatial networks, that neither sf, neither tidygraph has functions to calculate them. One such measure is the circuity of an edge, as described in this paper:

Circuity, the ratio of network to Euclidean distances, describes the directness of trips and the efficiency of transportation networks.

Describe the solution you'd like An edge measurement function, in the same style as tidygraphs "edge measures" group of functions, that calculates the circuity of a spatially explicit edge: edge_circuity.

luukvdmeer commented 4 years ago

This is implemented in the new version, along with other edge measures

idshklein commented 3 years ago

Suggestion: adding a parameter for self loop edges, in order to return NA instead of inf

luukvdmeer commented 3 years ago

Out of interest: when are you running into problems with Inf values?

idshklein commented 3 years ago

When I try to calculate mean neighborhood circuitry

On Fri, Jan 8, 2021, 21:06 Lucas van der Meer notifications@github.com wrote:

Out of interest: when are you running into problems with Inf values?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/luukvdmeer/sfnetworks/issues/51#issuecomment-756941204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5Q36Q4Z3L454CJRB7D4KDSY5JTRANCNFSM4NXCWJIQ .

luukvdmeer commented 3 years ago

Makes sense. I added the Inf_as_NaN value to return NaN instead of Inf. NaN is also returned when for some reason the edge length is 0. Then mean calculations (and others) can be run with na.rm = TRUE. I think it makes sense to even use the default of Inf_as_NaN = TRUE.