rafapereirabr / gtfs_to_igraph

R script to convert a GTFS feed into an igraph object for network analysis in R
19 stars 8 forks source link

assignment of edge weights has an error, I think #1

Open DOSull opened 5 years ago

DOSull commented 5 years ago

Hi, Found this useful messing with GTFS (thanks!) but I think there is an error in line 301

relations <- stop_times_edited[, .(weight = .N), by= .(stop_id, stop_id_to, route_id, route_type)]

which results in the edge weights being some effectively arbitrary nonsense. Corrected to

relations <- stop_times_edited[, .(weight = travel_time), by= .(stop_id, stop_id_to, route_id, route_type)]

and I got results more to my liking!

rafapereirabr commented 5 years ago

Hi David. thanks for reaching out. The intention in original code was to weight the edges by the number of trips (.N) between each pair of stops so it would consider the service frequency. I wrote this code when I was writting a paper on the intersection of complex networks and transport geography, looking at network science and accessibility.

However, I do recognize that it makes sense to weigh by travel_time, it depends on the purpose of the analysis. Are you doing routing analysis?

DOSull commented 5 years ago

my comment was based on the documentation which says "with information on route frequency and on travel time". I missed the first and was focused on the second.

Either way, it has become clear to me that the resulting network is of limited usefulness for detailed analysis, since it will tell you the 'nearness' (in some sense) of stops, but information about how routes chain places together over multiple stops at a particular time of day is lost in the summarisation.

Still a fun script to mess around with.

rafapereirabr commented 5 years ago

I see. David, it sounds like you're looking for clustering techniques / community detection in spatial networks. Perhaps you would be interested in having a look at these papers, if you haven't already: