Ticket #298: 298-arcmixing-0a0cbbf56e23.patch

File 298-arcmixing-0a0cbbf56e23.patch, 2.3 KB (added by Peter Kovacs, 12 years ago)
• lemon/network_simplex.h

```# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1246462102 -7200
# Node ID 0a0cbbf56e23a7cc36f5ee3bfd572c61a408d7f7
# Parent  cab85bd7859b6b89eee29e8db1619888a513e6a6
Add a parameter to control arc mixing in NS (#298)

diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h```
 a /// The constructor of the class. /// /// \param graph The digraph the algorithm runs on. NetworkSimplex(const GR& graph) : /// \param arc_mixing Indicate if the arcs have to be stored in a /// mixed order in the internal data structure. /// In special cases, it could lead to better overall performance, /// but it is usually slower. Therefore it is disabled by default. NetworkSimplex(const GR& graph, bool arc_mixing = false) : _graph(graph), _node_id(graph), _arc_id(graph), INF(std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : _last_succ.resize(all_node_num); _state.resize(max_arc_num); // Copy the graph (store the arcs in a mixed order) // Copy the graph int i = 0; for (NodeIt n(_graph); n != INVALID; ++n, ++i) { _node_id[n] = i; } int k = std::max(int(std::sqrt(double(_arc_num))), 10); i = 0; for (ArcIt a(_graph); a != INVALID; ++a) { _arc_id[a] = i; _source[i] = _node_id[_graph.source(a)]; _target[i] = _node_id[_graph.target(a)]; if ((i += k) >= _arc_num) i = (i % k) + 1; if (arc_mixing) { // Store the arcs in a mixed order int k = std::max(int(std::sqrt(double(_arc_num))), 10); int i = 0; for (ArcIt a(_graph); a != INVALID; ++a) { _arc_id[a] = i; _source[i] = _node_id[_graph.source(a)]; _target[i] = _node_id[_graph.target(a)]; if ((i += k) >= _arc_num) i = (i % k) + 1; } } else { // Store the arcs in the original order int i = 0; for (ArcIt a(_graph); a != INVALID; ++a, ++i) { _arc_id[a] = i; _source[i] = _node_id[_graph.source(a)]; _target[i] = _node_id[_graph.target(a)]; } } // Initialize maps