calculateCriticalPathTasks identifies tasks on the critical path
(tasks []*model.Task, taskMap map[string]*model.Task)
| 132 | |
| 133 | // calculateCriticalPathTasks identifies tasks on the critical path |
| 134 | func calculateCriticalPathTasks(tasks []*model.Task, taskMap map[string]*model.Task) map[string]bool { |
| 135 | criticalPath := make(map[string]bool) |
| 136 | |
| 137 | // Calculate depth for each task |
| 138 | depthMap := calculateDepthMap(tasks, taskMap) |
| 139 | |
| 140 | // Find maximum depth |
| 141 | maxDepth := 0 |
| 142 | for _, depth := range depthMap { |
| 143 | if depth > maxDepth { |
| 144 | maxDepth = depth |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Mark tasks on critical path (those with max depth) |
| 149 | for taskID, depth := range depthMap { |
| 150 | if depth == maxDepth { |
| 151 | criticalPath[taskID] = true |
| 152 | // Mark all dependencies on the path |
| 153 | markCriticalPathDependencies(taskID, taskMap, depthMap, maxDepth, criticalPath) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | return criticalPath |
| 158 | } |
| 159 | |
| 160 | // markCriticalPathDependencies recursively marks dependencies on critical path |
| 161 | func markCriticalPathDependencies( |