Sub topic 5
The forward pass: earliest start and finish
This chapter assumes you can read a task list with durations and predecessors. It also assumes you know what a dependency is and can do day arithmetic. The code uses Python dictionaries and loops. The chapter shows how to compute the earliest time each activity can start and finish, and how those times give the minimum project duration.
What the forward pass computes
The forward pass walks through the activity network from the start to the end. For every activity it records two numbers:
- Earliest start (ES) is the earliest time the activity can begin, given that all its predecessors must finish first.
- Earliest finish (EF) is the earliest time the activity can end. It equals ES plus the activity's duration.
The word "earliest" matters. These values assume every predecessor finishes as soon as possible and that nothing else delays the activity. They describe the best case allowed by the logic of the network, not a commitment.
The largest EF in the network is the minimum project duration. No schedule that respects the dependencies can finish sooner.
The two rules
The whole method rests on two formulas:
- ES of an activity = the maximum EF among its predecessors. If it has no predecessors, ES = 0.
- EF of an activity = ES + duration.
The first rule uses a maximum because an activity with several predecessors must wait for all of them. The slowest predecessor decides when it can start. This is the most common place for errors. Learners often average the predecessor finish times, or pick the first one listed.
The predecessor that sets the maximum is the driving predecessor. The others finish earlier and leave a gap before the successor starts. That gap is the seed of float, which a later chapter covers.
Time convention
This chapter treats time as points on a line. Day 0 is the start of the project, and an activity of duration 3 that starts at 0 finishes at 3. In this convention, an activity that finishes at 3 hands over to a successor that starts at 3, with no gap or overlap.
Many tools and textbooks count whole days instead. The first day is day 1, and an activity occupies the days from ES through EF, so EF = ES + duration − 1. A successor then starts at the predecessor's EF + 1. Both conventions give the same project length. Pick one and apply it consistently, and check which one your tool uses before you compare numbers.
A worked example
Take four activities:
| Activity | Duration (days) | Predecessors |
|---|---|---|
| A | 3 | none |
| B | 2 | A |
| C | 4 | A |
| D | 3 | B, C |
Work through them in an order where predecessors come first.
- A has no predecessors, so ES = 0 and EF = 0 + 3 = 3.
- B has predecessor A, so ES = 3 and EF = 3 + 2 = 5.
- C also has predecessor A, so ES = 3 and EF = 3 + 4 = 7.
- D has predecessors B (EF 5) and C (EF 7). ES = max(5, 7) = 7, and EF = 7 + 3 = 10.
The minimum project duration is 10 days. C is D's driving predecessor. B finishes at day 5, but D cannot start until day 7, so B has two days of slack.
Why order matters
The rules only work if every predecessor already has its EF when you reach a task. So you must process activities in a topological order. In that order, each activity appears after all of its predecessors.
In a small network you can do this by eye. In a larger one, a list that happens to be in the wrong order will give wrong answers or errors, because you will read an EF that does not exist yet. The Python graphlib module can produce a valid order for you. It also raises an error if the network contains a cycle, because a cycle has no valid order. Checking the network for cycles and missing links is the subject of the previous chapter, and you should do it before you calculate.
The forward pass in code
This function applies the two rules exactly as written above.
from graphlib import TopologicalSorter
tasks = {
# name: (duration in days, predecessors)
"A": (3, []),
"B": (2, ["A"]),
"C": (4, ["A"]),
"D": (3, ["B", "C"]),
}
def forward_pass(tasks):
# TopologicalSorter takes a mapping of node -> its predecessors.
graph = {t: preds for t, (_, preds) in tasks.items()}
es, ef = {}, {}
for t in TopologicalSorter(graph).static_order():
duration, preds = tasks[t]
es[t] = max((ef[p] for p in preds), default=0)
ef[t] = es[t] + duration
return es, ef
es, ef = forward_pass(tasks)
for t in tasks:
print(t, es[t], ef[t])
print("Project duration:", max(ef.values()))Running it prints:
A 0 3
B 3 5
C 3 7
D 7 10
Project duration: 10The expression max(..., default=0) handles activities with no predecessors. Without default, max of an empty sequence raises an error. If a predecessor name is misspelled, the sorter treats it as a new node and the lookup tasks[t] fails with a KeyError. That failure is useful, because it points to a missing activity.
Edge cases
Several start activities. A network can have more than one activity with no predecessors. Each one gets ES = 0. They run in parallel, and the project starts when the first of them starts.
Several end activities. The project duration is the maximum EF over all activities, not the EF of the last one in your list. Some tools add a single finish milestone that depends on every end activity. The maximum then appears as that milestone's ES.
Milestones. A milestone has duration 0, so its ES and EF are equal. It still follows the max rule. A milestone such as "design approved" with three predecessors lands on the latest of the three finish times.
Start constraints. A task may have a rule such as "must not start before day 5", for example because a vendor delivers then. In that case ES is the larger of the value from predecessors and the constraint. Such constraints can make a task appear delayed even though no predecessor causes it, so note them when you explain the result.
Calendars. Durations are usually in working days. A task that is 3 working days long and starts on a Thursday finishes the following Monday if weekends are non-working. The forward pass logic is unchanged. A scheduling tool converts between working-day counts and calendar dates for you. If you do the arithmetic by hand, do it in working days and convert to dates at the end.
Lags and other link types. The rules above assume each link means "finish to start" with no delay. A lag adds or subtracts time between two activities, and other link types change which end of the predecessor is used. A later chapter covers these. For now, treat every dependency as finish to start.
Common mistakes
- Adding instead of taking the maximum. Summing the EFs of all predecessors counts parallel work as if it were sequential and overstates the duration.
- Taking the first predecessor. The ES must come from the latest finishing predecessor, not the first one in the list.
- Forgetting the duration. Setting EF = ES shows up when a milestone is handled correctly but a normal task is not. Check that EF = ES + duration for every task.
- Mixing conventions. Using the day-0 convention for some tasks and the day-1 convention for others produces off-by-one errors that accumulate along the path.
- Wrong processing order. Reading a predecessor's EF before computing it gives stale or missing values.
What you can read from the result
After the forward pass you know the minimum project duration. You also know, for each task, the driving predecessor, which is the one whose EF equals the task's ES. Tracing driving predecessors back from the last finishing task reveals a longest chain. That chain is a candidate critical path.
The forward pass alone does not tell you how much a task can slip without delaying the project. In the example, B finishes at day 5 but is not needed until day 7. Finding that out requires the latest times, which come from the backward pass in the next chapter.
Exercise
A network has these activities (duration in days, predecessors): P (2, none), Q (5, P), R (3, P), S (4, none), T (2, Q, R, S). Run the forward pass using the day-0 convention. What are the ES and EF of every activity, what is the minimum project duration, and which predecessor drives T?
Show answer
P: ES 0, EF 2. Q: ES 2, EF 7. R: ES 2, EF 5. S: ES 0, EF 4. T: ES = max(7, 5, 4) = 7, so EF = 7 + 2 = 9. The minimum project duration is 9 days. Q drives T, because its EF of 7 is the largest among T's predecessors. R and S finish earlier and wait.
Exercise
A task X has duration 4 and two predecessors that finish at day 6 and day 9. A vendor constraint says X must not start before day 11. What are X's ES and EF?
Show answer
The predecessors allow a start at max(6, 9) = 9. The constraint requires a start no earlier than 11. ES is the larger of the two, so ES = 11 and EF = 11 + 4 = 15. The constraint, not a predecessor, drives X.