'Propagate function time ratio along the function calls.
Must be called after finding the cycles.
See also:
- http://citeseer.ist.psu.edu/graham82gprof.html'

def integrate(self, outevent, inevent):

    assert (outevent not in self)
    for function in compat_itervalues(self.functions):
        assert (outevent not in function)
        assert (inevent in function)
        for call in compat_itervalues(function.calls):
            assert (outevent not in call)
            if (call.callee_id != function.id):
                assert (call.ratio is not None)
    for cycle in self.cycles:
        total = inevent.null()
        for function in compat_itervalues(self.functions):
            total = inevent.aggregate(total, function[inevent])
        self[inevent] = total
    total = inevent.null()
    for function in compat_itervalues(self.functions):
        total = inevent.aggregate(total, function[inevent])
        self._integrate_function(function, outevent, inevent)
    self[outevent] = total
