Crate transit_grid
source ·Expand description
TransitGrid
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.
Project Status
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.
Design Goals
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
Future Work
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.
License
TransitGrid is licensed under the MIT License.
Modules
- TransitNet is a Rust library for representing, manipulating, and performing computations on transit networks. It provides a set of core data structures and algorithms that are commonly used in transit network analysis.
- This module provides basic structures for representing a transit network. It provides
TransitNode
andTransitEdge
structures, along with ID types for them. TheTransitNode
represents a node in the transit network, while theTransitEdge
represents a connection between two nodes. The module also providesAccessability
, an enum for representing the accessibility of nodes in the network. - This module contains the definition and implementation of various types of graphs used to represent and manipulate transit networks.
- This module provides abstractions and implementations for modifying a transit network. A transit network is represented as a graph, where each node is a
TransitNode
(a point in the transit network where a vehicle can stop) and each edge represents a path (TransitEdge
) between two transit nodes. The main trait provided by this module isTransitNetworkModifier
. - The
prelude
module re-exports the most commonly used items from thecore
,graphs
, andoperations
modules,