This project is a Critical Path Method (CPM) network diagram generator for project management.
It reads activity data from a CSV file, computes scheduling metrics (ES, EF, LS, LF, TF), and produces a clean network diagram with critical paths highlighted.
The diagrams are rendered with Graphviz in a grid-like layout with orthogonal connectors.
- Computes:
- Earliest Start (ES)
- Earliest Finish (EF)
- Latest Start (LS)
- Latest Finish (LF)
- Total Float (TF)
- Highlights the critical path (zero float) in red
- Outputs diagrams as PNG, SVG, or PDF
- Grid-based layout with square connectors for clarity
- Simple CSV input format
We recommend using conda to manage the environment.
# Create a new environment
conda create -n cpm-diagram python=3.10 -y
conda activate cpm-diagram
# Install dependencies
pip install pandas graphvizMake sure you have the Graphviz binaries installed. On Ubuntu/Debian:
sudo apt-get install graphvizOn macOS (with Homebrew):
brew install graphviz
Example project.csv:
id,description,duration,predecessors
A,Kickoff,1,
B,Design,5,A
C,Procurement,4,A
D,Implementation,7,B,C
E,Testing,3,Did: Unique activity ID (letters/numbers)description: Short task descriptionduration: Task duration in dayspredecessors: Comma-separated list of task IDs (leave blank if none)
python cpm_network_diagram.py project.csv output.pngThis generates output.png with the full CPM network diagram.
You can also output to SVG or PDF by changing the file extension:
python cpm_network_diagram.py project.csv output.svg
python cpm_network_diagram.py project.csv output.pdfFor the demo CSV above, the generated diagram looks like this:
MIT License – feel free to use and adapt this tool in your own projects.
