12 #include "../stdafx.h"
13 #include "../core/pool_func.hpp"
16 #include "../safeguards.h"
32 this->demand = demand;
57 for (NodeID node1 = 0; node1 < this->
Size(); ++node1) {
60 for (NodeID node2 = 0; node2 < this->
Size(); ++node2) {
68 void LinkGraph::Compress()
71 for (NodeID node1 = 0; node1 < this->
Size(); ++node1) {
72 this->
nodes[node1].supply /= 2;
73 for (NodeID node2 = 0; node2 < this->
Size(); ++node2) {
74 BaseEdge &edge = this->
edges[node1][node2];
75 if (edge.capacity > 0) {
91 NodeID first = this->
Size();
92 for (NodeID node1 = 0; node1 < other->
Size(); ++node1) {
94 NodeID new_node = this->
AddNode(st);
98 for (NodeID node2 = 0; node2 < node1; ++node2) {
101 forward = other->
edges[node1][node2];
102 backward = other->
edges[node2][node1];
111 new_start = other->
edges[node1][node1];
123 assert(id < this->
Size());
125 NodeID last_node = this->
Size() - 1;
126 for (NodeID i = 0; i <= last_node; ++i) {
127 (*this)[i].RemoveEdge(
id);
131 while (next != INVALID_NODE) {
132 if (next == last_node) {
139 node_edges[id] = node_edges[last_node];
161 NodeID new_node = this->
Size();
166 max(new_node + 1U, this->
edges.Height()));
174 new_edges[new_node].
next_edge = INVALID_NODE;
176 for (NodeID i = 0; i <= new_node; ++i) {
178 this->
edges[i][new_node].Init();
193 assert(this->
index != to);
213 assert(capacity > 0);
214 assert(usage <= capacity);
215 if (this->
edges[to].capacity == 0) {
216 this->AddEdge(to, capacity, usage, mode);
218 (*this)[to].Update(capacity, usage, mode);
228 if (this->
index == to)
return;
235 NodeID prev = this->
index;
236 NodeID next = this->
edges[this->
index].next_edge;
237 while (next != INVALID_NODE) {
245 next = this->
edges[next].next_edge;
263 assert(this->edge.capacity > 0);
264 assert(capacity >= usage);
267 this->edge.capacity += capacity;
268 this->edge.usage += usage;
270 this->edge.capacity =
max(this->edge.capacity, capacity);
271 this->edge.usage =
max(this->edge.usage, usage);
284 assert(this->
Size() == 0);
288 for (uint i = 0; i < size; ++i) {
289 this->
nodes[i].Init();
291 for (uint j = 0; j < size; ++j) column[j].
Init();