Boost C++ Libraries: Ticket #12038: Max-flow algorithms not working with named parameters. https://svn.boost.org/trac10/ticket/12038 <p> The named parameter called "edge capacity" is not working. As explained at the end of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8791" title="#8791: Bugs: successfull compilation depends on header order in Graph (closed: fixed)">#8791</a>, this is due to a slight inversion: </p> <p> The line in <code>boost/graph/named_function_params.hpp:326</code> </p> <div class="wiki-code"><div class="code"><pre><span class="k">typedef</span> <span class="k">typename</span> <span class="n">detail</span><span class="o">::</span><span class="n">choose_iml_result</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">mph</span><span class="o">::</span><span class="n">true_</span><span class="p">,</span> <span class="n">Graph</span><span class="p">,</span> <span class="k">typename</span> <span class="n">get_param_type</span><span class="o">&lt;</span><span class="n">Params</span><span class="p">,</span> <span class="n">edge_capacity_t</span><span class="o">&gt;::</span><span class="n">type</span><span class="p">,</span> <span class="n">edge_capacity_t</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">CapacityEdgeMap</span><span class="p">;</span> </pre></div></div><p> should rather be </p> <div class="wiki-code"><div class="code"><pre><span class="k">typedef</span> <span class="k">typename</span> <span class="n">detail</span><span class="o">::</span><span class="n">choose_iml_result</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">mph</span><span class="o">::</span><span class="n">true_</span><span class="p">,</span> <span class="n">Graph</span><span class="p">,</span> <span class="k">typename</span> <span class="n">get_param_type</span><span class="o">&lt;</span><span class="n">edge_capacity_t</span><span class="p">,</span> <span class="n">Params</span><span class="o">&gt;::</span><span class="n">type</span><span class="p">,</span> <span class="n">edge_capacity_t</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">CapacityEdgeMap</span><span class="p">;</span> </pre></div></div><p> Here are the max-flow algorithms that are currently not working with the named parameter "Edge Capacity": </p> <ul><li>edmonds_karp_max_flow, </li><li>push_relabel_max_flow, </li><li>boykov_kolmogorov_max_flow. </li></ul><hr /> <p> Minimal not-working example: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/config.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;string&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/graph/edmonds_karp_max_flow.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/graph/adjacency_list.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/graph/read_dimacs.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/graph/graph_utility.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/graph/find_flow_cost.hpp&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">adjacency_list_traits</span><span class="o">&lt;</span><span class="n">vecS</span><span class="p">,</span><span class="n">vecS</span><span class="p">,</span><span class="n">directedS</span><span class="o">&gt;</span> <span class="n">traits</span><span class="p">;</span> <span class="k">struct</span> <span class="n">edge_t</span> <span class="p">{</span> <span class="kt">double</span> <span class="n">capacity</span><span class="p">;</span> <span class="kt">float</span> <span class="n">cost</span><span class="p">;</span> <span class="kt">float</span> <span class="n">residual_capacity</span><span class="p">;</span> <span class="n">traits</span><span class="o">::</span><span class="n">edge_descriptor</span> <span class="n">reversed_edge</span><span class="p">;</span> <span class="p">};</span> <span class="k">struct</span> <span class="n">node_t</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">name</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">default_color_type</span> <span class="n">color</span><span class="p">;</span> <span class="n">traits</span><span class="o">::</span><span class="n">edge_descriptor</span> <span class="n">predecessor</span><span class="p">;</span> <span class="p">};</span> <span class="k">typedef</span> <span class="n">adjacency_list</span> <span class="o">&lt;</span> <span class="n">listS</span><span class="p">,</span> <span class="n">vecS</span><span class="p">,</span> <span class="n">directedS</span><span class="p">,</span> <span class="n">node_t</span><span class="p">,</span> <span class="n">edge_t</span> <span class="o">&gt;</span> <span class="n">Graph</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">Graph</span> <span class="n">g</span><span class="p">;</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="kt">double</span> <span class="n">edge_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">capacity</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">edge_t</span><span class="o">::</span><span class="n">capacity</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="kt">float</span> <span class="n">edge_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">cost</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">edge_t</span><span class="o">::</span><span class="n">cost</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="kt">float</span> <span class="n">edge_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">residual_capacity</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">edge_t</span><span class="o">::</span><span class="n">residual_capacity</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="n">traits</span><span class="o">::</span><span class="n">edge_descriptor</span> <span class="n">edge_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">rev</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">edge_t</span><span class="o">::</span><span class="n">reversed_edge</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">node_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">name</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">node_t</span><span class="o">::</span><span class="n">name</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">default_color_type</span> <span class="n">node_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">col</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">node_t</span><span class="o">::</span><span class="n">color</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">property_map</span> <span class="o">&lt;</span> <span class="n">Graph</span><span class="p">,</span> <span class="n">traits</span><span class="o">::</span><span class="n">edge_descriptor</span> <span class="n">node_t</span><span class="o">::*</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">pred</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="o">&amp;</span><span class="n">node_t</span><span class="o">::</span><span class="n">predecessor</span><span class="p">,</span> <span class="n">g</span><span class="p">);</span> <span class="n">traits</span><span class="o">::</span><span class="n">vertex_descriptor</span> <span class="n">s</span><span class="p">,</span> <span class="n">t</span><span class="p">;</span> <span class="n">read_dimacs_max_flow</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">capacity</span><span class="p">,</span> <span class="n">rev</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="n">t</span><span class="p">);</span> <span class="c1">// XXX The &quot;named parameter version&quot; (producing errors)</span> <span class="c1">// XXX I chose to show the error with edmonds_karp_max_flow().</span> <span class="n">flow</span> <span class="o">=</span> <span class="n">edmonds_karp_max_flow</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">capacity_map</span><span class="p">(</span><span class="n">capacity</span><span class="p">)</span> <span class="p">.</span><span class="n">residual_capacity_map</span><span class="p">(</span><span class="n">residual_capacity</span><span class="p">)</span> <span class="p">.</span><span class="n">reverse_edge_map</span><span class="p">(</span><span class="n">rev</span><span class="p">)</span> <span class="p">.</span><span class="n">color_map</span><span class="p">(</span><span class="n">col</span><span class="p">)</span> <span class="p">.</span><span class="n">predecessor_map</span><span class="p">(</span><span class="n">pred</span><span class="p">));</span> <span class="k">return</span> <span class="n">EXIT_SUCCESS</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12038 Trac 1.4.3 Maël Valais <mael.valais@…> Wed, 02 Mar 2016 14:57:24 GMT component changed; owner set https://svn.boost.org/trac10/ticket/12038#comment:1 https://svn.boost.org/trac10/ticket/12038#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Jeremiah Willcock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">graph</span> </li> </ul> Ticket Maël Valais <mael.valais@…> Wed, 02 Mar 2016 15:38:27 GMT <link>https://svn.boost.org/trac10/ticket/12038#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12038#comment:2</guid> <description> <p> Added PR on Github: <a class="ext-link" href="https://github.com/boostorg/graph/pull/60"><span class="icon">​</span>https://github.com/boostorg/graph/pull/60</a> </p> </description> <category>Ticket</category> </item> <item> <author>Maël Valais <mael.valais@…></author> <pubDate>Tue, 03 May 2016 08:44:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12038#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12038#comment:3</guid> <description> <p> I re-submitted the patch in <a class="ext-link" href="https://github.com/boostorg/graph/pull/61"><span class="icon">​</span>https://github.com/boostorg/graph/pull/61</a>. It has been accepted yesterday, we may close that issue! </p> </description> <category>Ticket</category> </item> </channel> </rss>