Building a simulation engine using Python, NetworkX, and Streamlit to model cascading failures in supply chain networks.
Most supply chain failures don’t happen all at once — they unfold in cascades.
I recently built a graph-based simulation engine to understand how disruptions propagate through complex logistics networks. The system models supply chains as directed weighted graphs and simulates how failures spread step-by-step across infrastructure.
In this post, I’ll walk through how I built it, how the cascade logic works, and what I learned from designing the system.
Tech Stack
- Python
- NetworkX
- Streamlit
- Pandas
- Pytest (for deterministic validation)
Modeling the Network
The supply chain is modeled as a directed weighted graph:
python
import networkx as nx
G = nx.DiGraph()
G.add_node("A", type="factory")
G.add_node("B", type="hub")
G.add_node("D", type="market")
G.add_edge("A", "B", weight=2)
G.add_edge("B", "D", weight=2)
Routing is computed using Dijkstra’s algorithm:
- nx.dijkstra_path(G, "A", "D", weight="weight")
## Explore the Project
👉 GitHub: https://github.com/jithinmathws/supplyChainRiskAnalyzer
If you work with graph systems, simulation engines, or infrastructure modeling, I’d love to hear your thoughts.
Top comments (0)