* Scale all shares from link graph's runtime to monthly values. * @param runtime Time the link graph has been running without compression. * @pre runtime must be greater than 0 as we don't want infinite flow values. */
| 5193 | * @pre runtime must be greater than 0 as we don't want infinite flow values. |
| 5194 | */ |
| 5195 | void FlowStat::ScaleToMonthly(uint runtime) |
| 5196 | { |
| 5197 | assert(runtime > 0); |
| 5198 | SharesMap new_shares; |
| 5199 | uint share = 0; |
| 5200 | for (auto i : this->shares) { |
| 5201 | share = std::max(share + 1, i.first * 30 / runtime); |
| 5202 | new_shares[share] = i.second; |
| 5203 | if (this->unrestricted == i.first) this->unrestricted = share; |
| 5204 | } |
| 5205 | this->shares.swap(new_shares); |
| 5206 | } |
| 5207 | |
| 5208 | /** |
| 5209 | * Add some flow from "origin", going via "via". |