Critical Path Calculator

Critical Path Calculator

Use this calculator to determine the critical path and overall project duration for your project activities. Enter each activity's name, its duration, and any direct predecessors. The calculator will then compute the Early Start (ES), Early Finish (EF), Late Start (LS), Late Finish (LF), Slack, and identify critical activities.

Add Activity

Project Activities

Activity ID Duration Predecessors Action
.critical-path-calculator-container { font-family: Arial, sans-serif; max-width: 900px; margin: 20px auto; padding: 20px; border: 1px solid #ddd; border-radius: 8px; background-color: #f9f9f9; } .critical-path-calculator-container h2, .critical-path-calculator-container h3 { color: #333; text-align: center; margin-bottom: 15px; } .critical-path-calculator-container p { margin-bottom: 20px; line-height: 1.6; } .calculator-inputs, .activity-list, .calculator-results { background-color: #fff; padding: 15px; border-radius: 5px; margin-bottom: 20px; border: 1px solid #eee; } .input-group { margin-bottom: 10px; } .input-group label { display: block; margin-bottom: 5px; font-weight: bold; color: #555; } .input-group input[type="text"], .input-group input[type="number"] { width: calc(100% – 22px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; } .critical-path-calculator-container button { background-color: #007bff; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 1em; margin-right: 10px; margin-top: 10px; } .critical-path-calculator-container button:hover { background-color: #0056b3; } .critical-path-calculator-container button.remove-btn { background-color: #dc3545; } .critical-path-calculator-container button.remove-btn:hover { background-color: #c82333; } #activityTable { width: 100%; border-collapse: collapse; margin-top: 15px; } #activityTable th, #activityTable td { border: 1px solid #ddd; padding: 8px; text-align: left; } #activityTable th { background-color: #f2f2f2; font-weight: bold; } .calculator-results table { width: 100%; border-collapse: collapse; margin-top: 15px; } .calculator-results th, .calculator-results td { border: 1px solid #ddd; padding: 8px; text-align: center; } .calculator-results th { background-color: #e9ecef; font-weight: bold; } .critical-activity { background-color: #fff3cd; /* Light yellow for critical path */ font-weight: bold; } .critical-path-summary { margin-top: 20px; padding: 10px; background-color: #e2f0ff; border: 1px solid #b8daff; border-radius: 5px; } .critical-path-summary p { margin: 5px 0; font-size: 1.1em; } .error-message { color: red; font-weight: bold; margin-top: 10px; } var activities = []; var activityCounter = 0; function addActivity() { var activityIdInput = document.getElementById('activityId'); var activityDurationInput = document.getElementById('activityDuration'); var activityPredecessorsInput = document.getElementById('activityPredecessors'); var id = activityIdInput.value.trim(); var duration = parseFloat(activityDurationInput.value); var predecessorsString = activityPredecessorsInput.value.trim(); var predecessors = predecessorsString ? predecessorsString.split(',').map(function(p) { return p.trim(); }) : []; if (!id) { alert('Activity Name/ID cannot be empty.'); return; } if (isNaN(duration) || duration < 0) { alert('Duration must be a non-negative number.'); return; } if (activities.some(function(a) { return a.id === id; })) { alert('Activity with this ID already exists. Please use a unique ID.'); return; } activities.push({ id: id, duration: duration, predecessors: predecessors, es: 0, ef: 0, ls: 0, lf: 0, slack: 0, critical: false, successors: [] // Will be populated during calculation }); renderActivityList(); activityIdInput.value = ''; activityDurationInput.value = '1'; activityPredecessorsInput.value = ''; } function removeActivity(idToRemove) { activities = activities.filter(function(activity) { return activity.id !== idToRemove; }); renderActivityList(); } function renderActivityList() { var tbody = document.getElementById('activityListTableBody'); tbody.innerHTML = ''; if (activities.length === 0) { tbody.innerHTML = 'No activities added yet.'; return; } activities.forEach(function(activity) { var row = tbody.insertRow(); row.insertCell(0).textContent = activity.id; row.insertCell(1).textContent = activity.duration; row.insertCell(2).textContent = activity.predecessors.join(', ') || 'None'; var actionCell = row.insertCell(3); var removeBtn = document.createElement('button'); removeBtn.textContent = 'Remove'; removeBtn.className = 'remove-btn'; removeBtn.onclick = function() { removeActivity(activity.id); }; actionCell.appendChild(removeBtn); }); } function clearAllActivities() { if (confirm('Are you sure you want to clear all activities?')) { activities = []; renderActivityList(); document.getElementById('criticalPathResult').innerHTML = "; } } function calculateCriticalPath() { var resultDiv = document.getElementById('criticalPathResult'); resultDiv.innerHTML = "; if (activities.length === 0) { resultDiv.innerHTML = 'Please add activities to calculate the critical path.'; return; } // Reset all calculated values and successors activities.forEach(function(activity) { activity.es = 0; activity.ef = 0; activity.ls = 0; activity.lf = 0; activity.slack = 0; activity.critical = false; activity.successors = []; }); // Build successor list and check for invalid predecessors var activityMap = {}; activities.forEach(function(activity) { activityMap[activity.id] = activity; }); var invalidPredecessorFound = false; activities.forEach(function(activity) { activity.predecessors.forEach(function(pId) { if (!activityMap[pId]) { resultDiv.innerHTML = 'Error: Predecessor "' + pId + '" for activity "' + activity.id + '" not found.'; invalidPredecessorFound = true; return; } activityMap[pId].successors.push(activity.id); }); if (invalidPredecessorFound) return; }); if (invalidPredecessorFound) return; // Forward Pass (ES, EF) // Iterate multiple times to ensure all dependencies are resolved // A fixed number of iterations (e.g., activities.length * 2) is a simple way to handle topological sort implicitly for acyclic graphs. for (var i = 0; i < activities.length * 2; i++) { activities.forEach(function(activity) { var maxPredecessorEF = 0; activity.predecessors.forEach(function(pId) { maxPredecessorEF = Math.max(maxPredecessorEF, activityMap[pId].ef); }); activity.es = maxPredecessorEF; activity.ef = activity.es + activity.duration; }); } // Determine Project Duration var projectDuration = 0; activities.forEach(function(activity) { projectDuration = Math.max(projectDuration, activity.ef); }); // Backward Pass (LS, LF) // Initialize LF for end activities, then iterate activities.forEach(function(activity) { if (activity.successors.length === 0) { // End activities activity.lf = projectDuration; activity.ls = activity.lf – activity.duration; } else { // Initialize with project duration for non-end activities, will be refined activity.lf = projectDuration; activity.ls = activity.lf – activity.duration; } }); for (var i = 0; i 0) { var minSuccessorLS = projectDuration; // Initialize with max possible activity.successors.forEach(function(sId) { minSuccessorLS = Math.min(minSuccessorLS, activityMap[sId].ls); }); activity.lf = minSuccessorLS; activity.ls = activity.lf – activity.duration; } }); } // Calculate Slack and identify Critical Path var criticalPathActivities = []; activities.forEach(function(activity) { activity.slack = activity.lf – activity.ef; activity.critical = (activity.slack === 0); if (activity.critical) { criticalPathActivities.push(activity.id); } }); // Display Results var resultsHtml = '

Critical Path Analysis Results

'; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; activities.forEach(function(activity) { var rowClass = activity.critical ? 'critical-activity' : "; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; resultsHtml += ''; }); resultsHtml += '
Activity IDDurationPredecessorsESEFLSLFSlackCritical
' + activity.id + '' + activity.duration + '' + (activity.predecessors.join(', ') || 'None') + '' + activity.es + '' + activity.ef + '' + activity.ls + '' + activity.lf + '' + activity.slack + '' + (activity.critical ? 'Yes' : 'No') + '
'; resultsHtml += '
'; resultsHtml += 'Total Project Duration: ' + projectDuration + ' units'; resultsHtml += 'Critical Path: ' + criticalPathActivities.join(' → ') + "; resultsHtml += '
'; resultDiv.innerHTML = resultsHtml; } // Initial render of activity list renderActivityList();

Understanding the Critical Path Method (CPM)

The Critical Path Method (CPM) is a project management technique used to identify the longest sequence of dependent activities in a project schedule. This sequence, known as the "critical path," determines the shortest possible time required to complete the project. Any delay in an activity on the critical path will directly delay the entire project.

Why is CPM Important?

  • Project Duration Estimation: CPM provides a clear estimate of the minimum project completion time.
  • Resource Allocation: By identifying critical activities, project managers can prioritize resources to ensure these tasks stay on schedule.
  • Risk Management: It highlights activities where delays would have the most significant impact, allowing for proactive risk mitigation.
  • Performance Monitoring: CPM serves as a baseline for tracking project progress and identifying deviations.

Key Terms in CPM

  • Activity: A specific task or piece of work required to complete the project. Each activity has a defined start and end point.
  • Duration: The estimated time required to complete an activity.
  • Predecessor: An activity that must be completed before another activity can begin.
  • Successor: An activity that cannot start until a preceding activity is finished.
  • Early Start (ES): The earliest time an activity can begin, assuming all predecessors are completed.
  • Early Finish (EF): The earliest time an activity can be completed (ES + Duration).
  • Late Start (LS): The latest time an activity can begin without delaying the project completion date.
  • Late Finish (LF): The latest time an activity can be completed without delaying the project completion date (LF – Duration).
  • Slack (Float): The amount of time an activity can be delayed without delaying the project's overall completion date. It's calculated as LF – EF or LS – ES.
  • Critical Activity: An activity with zero slack. These activities are on the critical path.
  • Critical Path: The sequence of critical activities from the project start to finish. It represents the longest path through the project network diagram and determines the minimum project duration.

How the Calculator Works

This Critical Path Calculator simplifies the CPM process for you:

  1. Input Activities: You enter each project activity with a unique ID, its estimated duration, and any direct predecessors.
  2. Forward Pass: The calculator performs a "forward pass" to determine the Early Start (ES) and Early Finish (EF) for each activity. It starts with activities that have no predecessors (ES=0) and moves forward, calculating the ES of subsequent activities based on the EF of their predecessors.
  3. Project Duration: The maximum EF among all activities determines the total project duration.
  4. Backward Pass: Next, a "backward pass" is executed. Starting from the project duration (which is the LF for the last activities), it works backward to calculate the Late Start (LS) and Late Finish (LF) for each activity.
  5. Slack Calculation: For each activity, the slack (LF – EF) is calculated.
  6. Critical Path Identification: Activities with zero slack are identified as critical. The sequence of these activities forms the critical path.

How to Use This Calculator

  1. Enter Activity Details:
    • Activity Name/ID: Provide a unique identifier for each task (e.g., "A", "Design", "Phase 1").
    • Duration (units): Input the estimated time for the activity (e.g., days, weeks, hours).
    • Predecessors (comma-separated): List the IDs of activities that must be completed before this one can start. If an activity has no predecessors (it's a starting activity), leave this field blank.
  2. Add Activity: Click the "Add Activity" button to add the entered task to your project list.
  3. Review Activities: The table will display all added activities. You can remove an activity if needed.
  4. Calculate: Once all activities are entered, click "Calculate Critical Path."
  5. View Results: The calculator will display a detailed table with ES, EF, LS, LF, Slack, and whether each activity is critical. It will also provide the total project duration and list the activities on the critical path.

Example Scenario

Let's consider a small project with the following activities:

Activity ID Duration Predecessors
A5None
B3None
C4A
D6A, B
E2C, D

If you input these activities into the calculator, you would find:

  • Total Project Duration: 13 units
  • Critical Path: A → D → E

This means the project cannot be completed in less than 13 units of time, and activities A, D, and E are crucial for maintaining this schedule.

Leave a Reply

Your email address will not be published. Required fields are marked *