Codechange: [Linkgraph] Drop node/edge wrappers from LinkGraphJob.

This commit is contained in:
Michael Lutz
2023-01-03 01:27:16 +01:00
parent 7352f812e6
commit 4d3da0cf14
7 changed files with 166 additions and 264 deletions

View File

@@ -19,35 +19,33 @@
void FlowMapper::Run(LinkGraphJob &job) const
{
for (NodeID node_id = 0; node_id < job.Size(); ++node_id) {
Node prev_node = job[node_id];
StationID prev = prev_node.Station();
PathList &paths = prev_node.Paths();
for (PathList::iterator i = paths.begin(); i != paths.end(); ++i) {
Path *path = *i;
Node &prev_node = job[node_id];
StationID prev = prev_node.base.station;
for (const Path *path : prev_node.paths) {
uint flow = path->GetFlow();
if (flow == 0) break;
Node node = job[path->GetNode()];
StationID via = node.Station();
StationID origin = job[path->GetOrigin()].Station();
Node &node = job[path->GetNode()];
StationID via = node.base.station;
StationID origin = job[path->GetOrigin()].base.station;
assert(prev != via && via != origin);
/* Mark all of the flow for local consumption at "first". */
node.Flows().AddFlow(origin, via, flow);
node.flows.AddFlow(origin, via, flow);
if (prev != origin) {
/* Pass some of the flow marked for local consumption at "prev" on
* to this node. */
prev_node.Flows().PassOnFlow(origin, via, flow);
prev_node.flows.PassOnFlow(origin, via, flow);
} else {
/* Prev node is origin. Simply add flow. */
prev_node.Flows().AddFlow(origin, via, flow);
prev_node.flows.AddFlow(origin, via, flow);
}
}
}
for (NodeID node_id = 0; node_id < job.Size(); ++node_id) {
/* Remove local consumption shares marked as invalid. */
Node node = job[node_id];
FlowStatMap &flows = node.Flows();
flows.FinalizeLocalConsumption(node.Station());
Node &node = job[node_id];
FlowStatMap &flows = node.flows;
flows.FinalizeLocalConsumption(node.base.station);
if (this->scale) {
/* Scale by time the graph has been running without being compressed. Add 1 to avoid
* division by 0 if spawn date == last compression date. This matches
@@ -58,10 +56,7 @@ void FlowMapper::Run(LinkGraphJob &job) const
}
}
/* Clear paths. */
PathList &paths = node.Paths();
for (PathList::iterator i = paths.begin(); i != paths.end(); ++i) {
delete *i;
}
paths.clear();
for (Path *i : node.paths) delete i;
node.paths.clear();
}
}