TransitGrid is a Rust library for simulating and analyzing transportation networks. It's designed to be flexible and general-purpose, capable of simulating trains on tracks, planes in the air, or ships at sea, and more.
TransitGrid is currently in the ideation phase. We're still designing the architecture of the library and determining its exact features. Please feel free to submit suggestions or feedback by opening an issue on our GitHub repository.
TransitGrid is built around two core data structures: the PhysicalGraph and the TopologyGraph.
-
PhysicalGraph: This is an undirected graph where each node represents a transit node (a point in the transit network where a vehicle can stop) and each edge represents a transit edge (a path between two transit nodes). The PhysicalGraph uses the UnGraph structure from the petgraph crate to internally represent this data. The PhysicalGraph maintains mappings between NodeId's and NodeIndexes (from petgraph), allowing for efficient conversion between the two.
-
TopologyGraph: Represents the topological graph of a transit network as a skew-symmetric graph. In this model, let
G = (V, E)
be the directed graph with a functionσ
mapping vertices ofG
to other vertices, satisfying the following properties:- For every vertex
v
,σ(v)
≠v
. - For every vertex
v
,σ(σ(v))
=v
. - For every edge
(u, v)
,(σ(v), σ(u))
must also be an edge.
In the context of the
TopologyGraph
, for each nodev
inV
, there are two nodes inV_t
, denoted asv_entry
andv_exit
. For each edge(u, v)
inE
, there are two directed edges inE_t
: one fromu_exit
tov_entry
and one fromv_exit
tou_entry
. The mathematical representation of this is:V_t = {v_entry, v_exit | v ∈ V}
E_t = {(u_exit, v_entry), (v_exit, u_entry) | (u, v) ∈ E}
This skew-symmetric model is based on the definition by Goldberg & Karzanov (1996). It is particularly useful for scenarios such as rail switches where the directionality of edges matters. The TopologyGraph uses the StableDiGraph structure from the petgraph crate for internal representation and maintains mappings between custom NodeId's/EdgeId's and petgraph's NodeIndexes/EdgeIndexes.
- For every vertex
TransitGrid will include several major components:
-
Graph Operations: Functions to add and remove nodes and edges from the graphs.
-
Graph Algorithms: Algorithms for finding the shortest path between two nodes, taking into account the current state of the Topology Graph.
We're excited about the possibilities that TransitGrid can offer, and we're looking forward to seeing what the community can build with it.
TransitGrid is licensed under the MIT License.