- if (link_table_.empty()) {
- /* Create and initialize Cost, Predecessor and Link tables */
- cost_table_.resize(table_size * table_size, DBL_MAX); /* link cost from host to host */
- predecessor_table_.resize(table_size * table_size, -1); /* predecessor host numbers */
- link_table_.resize(table_size * table_size, nullptr); /* actual link between src and dst */
+ if (link_table_.size() != table_size) {
+ /* Resize and initialize Cost, Predecessor and Link tables */
+ cost_table_.resize(table_size);
+ link_table_.resize(table_size);
+ predecessor_table_.resize(table_size);
+ for (auto& cost : cost_table_)
+ cost.resize(table_size, ULONG_MAX); /* link cost from host to host */
+ for (auto& link : link_table_)
+ link.resize(table_size); /* actual link between src and dst */
+ for (auto& predecessor : predecessor_table_)
+ predecessor.resize(table_size, -1); /* predecessor host numbers */