handle multiple activities with no successor
This commit is contained in:
parent
82befabe64
commit
c163aa0f23
|
@ -70,13 +70,7 @@ func (g *projectNetwork) forwardPass(toposort []*activity) {
|
||||||
// backwardPass computes the late times and slack for each activity using the
|
// backwardPass computes the late times and slack for each activity using the
|
||||||
// early times
|
// early times
|
||||||
func (g *projectNetwork) backwardPass(toposort []*activity) {
|
func (g *projectNetwork) backwardPass(toposort []*activity) {
|
||||||
n := len(toposort)
|
for i := len(toposort) - 1; i >= 0; i-- {
|
||||||
|
|
||||||
end := toposort[n-1]
|
|
||||||
end.lateFinish = end.earlyFinish
|
|
||||||
end.lateStart = end.lateFinish - end.duration
|
|
||||||
|
|
||||||
for i := n - 2; i >= 0; i-- {
|
|
||||||
a := toposort[i]
|
a := toposort[i]
|
||||||
g.setLateTimes(a)
|
g.setLateTimes(a)
|
||||||
}
|
}
|
||||||
|
@ -102,6 +96,10 @@ func (g *projectNetwork) setLateTimes(a *activity) {
|
||||||
s := successors.Node().(*activity)
|
s := successors.Node().(*activity)
|
||||||
lf = math.Min(lf, s.lateStart)
|
lf = math.Min(lf, s.lateStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if lf == math.Inf(1) {
|
||||||
|
lf = a.earlyFinish
|
||||||
|
}
|
||||||
a.lateFinish = lf
|
a.lateFinish = lf
|
||||||
a.lateStart = a.lateFinish - a.duration
|
a.lateStart = a.lateFinish - a.duration
|
||||||
a.slack = a.lateFinish - a.earlyFinish
|
a.slack = a.lateFinish - a.earlyFinish
|
||||||
|
|
Loading…
Reference in New Issue