Errors in graph calculations

This is the version for 2.1 branch corresponding to https://github.com/pfsense/pfsense/commit/f9983a874d6acf5fcf08a08606a6d19624af4438