Topology generator for US backbone networks with NetGraph scenario output.
Generates backbone network topologies from US Census Urban Areas (UAC) and TIGER/Line highway data. Outputs NetGraph scenario YAML with blueprints, components, risk groups, failure policies, and traffic matrices.
- Metro selection from UAC data with size filtering and hub overrides
- Equal-area projection, coordinate snapping, geometry pruning
- Corridor discovery via k-nearest metro adjacency and k-shortest paths
- Corridor risk groups with distance validation
- NetGraph scenario YAML with blueprints, components, failure policies, workflows
- Traffic matrix generation with seed metadata
- Schema validation and
ngraphworkflow execution checks
pip install topogengit clone https://github.com/networmix/TopoGen
cd TopoGen
make dev # Install in editable mode with dev dependencies
make check # Run full test suite# Show help
topogen --help
# Inspect configuration and data availability
topogen info config.yml
# Generate integrated metro + highway graph
topogen generate config.yml -o out_dir
# Build NetGraph scenario from integrated graph (requires previous generate)
topogen build config.yml -o out_dir
# Print scenario YAML to stdout without validation
topogen build config.yml --printfrom topogen import TopologyConfig, build_integrated_graph, save_to_json
# Load configuration
config = TopologyConfig.from_yaml("config.yml")
# Build integrated graph
graph = build_integrated_graph(config)
# Save to JSON
save_to_json(
graph,
"output/integrated_graph.json",
config.projection.target_crs,
config.output.formatting,
)YAML config validated by JSON schema (topogen/schemas/topogen_config.json). Example configs in examples/. Run make validate to check.
Place files in ./lib/ to override built-in libraries:
| File | Purpose |
|---|---|
blueprints.yml |
Topology templates (e.g., Clos fabrics) |
components.yml |
Hardware definitions (routers, optics) |
failure_policies.yml |
Failure mode definitions |
workflows.yml |
Analysis workflow steps |
User entries override built-ins by name.
topogen/ # Python package
cli.py # Command-line interface
config.py # Configuration loading/validation
integrated_graph.py # Graph construction
scenario_builder.py # NetGraph scenario generation
scenario/ # Scenario assembly modules
schemas/ # JSON schemas
validation/ # Validation audits
*_lib.py # Built-in libraries
examples/ # Example configurations
lib/ # Optional user library overrides
tests/ # Pytest suite
make dev # Setup environment
make check # Run pre-commit + validation + tests + lint
make check-ci # Run lint + validation + tests (CI mode)
make test # Run tests with coverage
make lint # Run linting only (ruff + pyright)
make validate # Validate config YAMLs against schema- Python: 3.11+
- ngraph: >= 0.12.0 (runtime dependency)
- Geo stack: geopandas, rasterio, pyproj, shapely (via dependencies)
- Data inputs (paths configured in YAML):
- UAC polygons (Census Urban Areas)
- TIGER/Line primary roads
- CONUS boundary (optional, for visualization)