How cedavidyang/network-risk works
Project type and purpose
• This is an open-source data-analysis and modeling toolkit for “Performance-Based Risk Assessment for Large-Scale Transportation Networks” using Transitional Markov Chain Monte Carlo (TMCMC).
• It consists of data assets (GIS network files), a core Python library (netrisk_TMCMC), and a set of top-level scripts that drive network preparation, case studies, risk computations, and results processing.
Main components of the system
a. Data Assets
• Directory: assets/
• Contains GIS shapefiles, GraphML, GeoPackage, etc., for the Oregon highway network.
b. Network Preparation
• Script: prepare_OR_network.py
• Reads raw GIS data, builds graph representations, serializes them for later use.
c. Core TMCMC Library
• Package: netrisk_TMCMC/
• highway_network.py — network data structures & I/O
• net_util.py — graph algorithms (path‐finding, vulnerability metrics)
• sampler.py — TMCMC sampler implementation
• type_verifier.py — input-type & parameter checks
• benchmark.py — performance measurement & logging
d. Use-Case Scripts
• case_I.py & case_II.py — parameterized examples of TMCMC runs (different seeds, asset sets)
• OR_risk.py — applies TMCMC method to compute risk on Oregon network
• OR_MCS_risk.py — Monte Carlo Simulation (crude MCS) baseline risk estimation
e. Output & Post-Processing
• Directory: results/ (CSV, Excel)
• Script: results_processing.py for aggregating, plotting, and summarizing results
f. Configuration & Environment
• .gitignore for excluding intermediate files (e.g., .DS_Store, large GPkg files)
Relationships & Data Flow
• Assets → prepare_OR_network.py → serialized network graphs
• prepare_OR_network.py → (uses netrisk_TMCMC.highway_network + net_util)
• case_I/II.py & OR_risk.py & OR_MCS_risk.py → import and call netrisk_TMCMC.sampler + other modules → generate raw risk results
• Scripts write to results/
• results_processing.py → reads results/ → produces final tables/plots
Key architectural patterns & principles
• Pipeline / workflow pattern: clear stages from data ingestion → model setup → sampling → results output
• Modular design: core algorithm code isolated in netrisk_TMCMC for reusability and testing
• Single-responsibility scripts: each top-level .py file has one main job (network prep, case runs, risk computing, post-processing)
• Separation of data (assets), code (library vs. scripts), and outputs (results)