Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Created March 15, 2018 14:55
Show Gist options
  • Save invisiblefunnel/54923ff2d8904bde9eec5c7436d72d91 to your computer and use it in GitHub Desktop.
Save invisiblefunnel/54923ff2d8904bde9eec5c7436d72d91 to your computer and use it in GitHub Desktop.

Timetable layout is a hard problem to solve for all cases. Here’s an approach which will not generalize to all routes, but works often enough to be useful (link). In short, build a directed graph of all adjacent stop pairs (edges) made by trips in the timetable and topologically sort it to get the “header row”, then layout the stop times accordingly. A fully generalized approach requires finding an approximation of the shortest common supersequence of the set of stopping patterns—which is definitely non-trivial to do really well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment