peartree
Convert from any graph formatto peartree Convert from peartreeto any other format
peartree is an open-source Python library, written by Kuan Butts, that converts public-transit schedules into directed network graphs suitable for sketch network analysis. It ingests General Transit Feed Specification (GTFS) feeds — the standard schedule format published as zipped CSV tables by transit agencies, closely related to GTFS — and produces an in-memory graph object rather than a new file format. Conceptually it plays the same role for transit data that OSMnx plays for street networks: it turns a domain-specific dataset into a graph that general-purpose algorithms can operate on.
Internally, peartree parses the GTFS feed with the Partridge library, which loads the relevant tables (stops, trips, stoptimes, routes, calendar) into pandas DataFrames and resolves service-day filtering. peartree then summarizes headways and travel times over a user-chosen time window — for example weekday morning peak, 7:00-10:00 — and emits a NetworkX directed multigraph. Nodes represent transit stops; edges represent stop-to-stop segments weighted by average in-vehicle travel time, and boarding penalties derived from average wait time (half the headway) are attached at stops. A typical workflow is getrepresentativefeed to pick the busiest service day, then loadfeedasgraph with the chosen time bounds.
Because the output is a standard NetworkX graph, the whole NetworkX algorithm ecosystem applies directly: shortest paths, betweenness and load centrality, spectral clustering, and connectivity measures. The graph can also be exported through NetworkX to interchange formats such as GraphML or GML, or merged with an OpenStreetMap walk network to build multimodal graphs, letting analysts combine walking access with scheduled transit. Users needing a faster backend have adapted peartree output into graph-tool for large-scale computation, and results interoperate with the broader igraph and Gephi tooling once serialized.
Its strengths are a small, focused API and a pragmatic time-averaged impedance model that makes accessibility and centrality studies quick to set up. The limitations follow from that same design: it produces an averaged, static snapshot rather than a true time-expanded schedule graph, so it does not capture exact departure times, transfer timing, or dynamic routing, and it approximates waits via headways. It targets sketch-level analysis and research, and active maintenance has been intermittent, so users should validate compatibility with current GTFS feeds and pandas versions.
Input Formats
Frequently Asked Questions
What graph file formats does peartree support?
See the list on this page — it shows every format peartree can read, write and display.
How do I import a graph into peartree?
Convert your file to a format peartree can read, then open it in peartree. Use GraphInOut to get a peartree-compatible file in seconds.
How do I convert a file so peartree can open it?
Use the convert links above — upload or paste your graph, pick a format peartree accepts and download the result, right in your browser.
