handle multiple activities with no successor

This commit is contained in:
filifa 2024-05-26 13:40:29 -05:00
parent 82befabe64
commit c163aa0f23
1 changed files with 5 additions and 7 deletions

View File

@ -70,13 +70,7 @@ func (g *projectNetwork) forwardPass(toposort []*activity) {
// backwardPass computes the late times and slack for each activity using the
// early times
func (g *projectNetwork) backwardPass(toposort []*activity) {
n := len(toposort)
end := toposort[n-1]
end.lateFinish = end.earlyFinish
end.lateStart = end.lateFinish - end.duration
for i := n - 2; i >= 0; i-- {
for i := len(toposort) - 1; i >= 0; i-- {
a := toposort[i]
g.setLateTimes(a)
}
@ -102,6 +96,10 @@ func (g *projectNetwork) setLateTimes(a *activity) {
s := successors.Node().(*activity)
lf = math.Min(lf, s.lateStart)
}
if lf == math.Inf(1) {
lf = a.earlyFinish
}
a.lateFinish = lf
a.lateStart = a.lateFinish - a.duration
a.slack = a.lateFinish - a.earlyFinish