Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../stdafx.h"
00013 #include "flowmapper.h"
00014
00019 void FlowMapper::Run(LinkGraphJob &job) const
00020 {
00021 for (NodeID node_id = 0; node_id < job.Size(); ++node_id) {
00022 Node prev_node = job[node_id];
00023 StationID prev = prev_node.Station();
00024 PathList &paths = prev_node.Paths();
00025 for (PathList::iterator i = paths.begin(); i != paths.end(); ++i) {
00026 Path *path = *i;
00027 uint flow = path->GetFlow();
00028 if (flow == 0) break;
00029 Node node = job[path->GetNode()];
00030 StationID via = node.Station();
00031 StationID origin = job[path->GetOrigin()].Station();
00032 assert(prev != via && via != origin);
00033
00034 node.Flows().AddFlow(origin, via, flow);
00035 if (prev != origin) {
00036
00037
00038 prev_node.Flows().PassOnFlow(origin, via, flow);
00039 } else {
00040
00041 prev_node.Flows().AddFlow(origin, via, flow);
00042 }
00043 }
00044 }
00045
00046 for (NodeID node_id = 0; node_id < job.Size(); ++node_id) {
00047
00048 Node node = job[node_id];
00049 FlowStatMap &flows = node.Flows();
00050 flows.FinalizeLocalConsumption(node.Station());
00051 if (this->scale) {
00052
00053
00054
00055 uint runtime = job.JoinDate() - job.Settings().recalc_time - job.LastCompression() + 1;
00056 for (FlowStatMap::iterator i = flows.begin(); i != flows.end(); ++i) {
00057 i->second.ScaleToMonthly(runtime);
00058 }
00059 }
00060
00061 PathList &paths = node.Paths();
00062 for (PathList::iterator i = paths.begin(); i != paths.end(); ++i) {
00063 delete *i;
00064 }
00065 paths.clear();
00066 }
00067 }