Boost C++ Libraries: Ticket #11374: find_flow_cost() not working with bundled or user-defined properties https://svn.boost.org/trac10/ticket/11374 <p> I tripped over that bug when trying to use <code>find_flow_cost()</code>. Using the source below, it won't compile. The error log is here : <a class="ext-link" href="http://pastebin.com/Gd3JdbuK"><span class="icon">​</span>http://pastebin.com/Gd3JdbuK</a> </p> <p> I think this is a problem in <code>boost/graph/find_flow_cost.hpp:18</code>. For example, line 19: </p> <pre class="wiki">typedef typename property_traits&lt;typename property_map&lt;Graph, edge_weight_t&gt;::const_type&gt;::value_type Cost; </pre><p> should rather be </p> <pre class="wiki">typedef typename property_traits&lt;Weight&gt;::value_type Cost; </pre><p> The same problem occurs line on 17 and 19. </p> <p> The minimum working example: </p> <pre class="wiki">//======================================================================= // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #include &lt;boost/config.hpp&gt; #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;boost/graph/edmonds_karp_max_flow.hpp&gt; #include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;boost/graph/read_dimacs.hpp&gt; #include &lt;boost/graph/graph_utility.hpp&gt; #include &lt;boost/graph/find_flow_cost.hpp&gt; using namespace boost; typedef adjacency_list_traits&lt;vecS,vecS,directedS&gt; traits; struct edge_t { double capacity; float cost; float residual_capacity; traits::edge_descriptor reversed_edge; }; struct node_t { std::string name; boost::default_color_type color; traits::edge_descriptor predecessor; }; typedef adjacency_list &lt; listS, vecS, directedS, node_t, edge_t &gt; Graph; int main() { Graph g; property_map &lt; Graph, double edge_t::* &gt;::type capacity = get(&amp;edge_t::capacity, g); property_map &lt; Graph, float edge_t::* &gt;::type cost = get(&amp;edge_t::cost, g); property_map &lt; Graph, float edge_t::* &gt;::type residual_capacity = get(&amp;edge_t::residual_capacity, g); property_map &lt; Graph, traits::edge_descriptor edge_t::* &gt;::type rev = get(&amp;edge_t::reversed_edge, g); property_map &lt; Graph, std::string node_t::* &gt;::type name = get(&amp;node_t::name, g); property_map &lt; Graph, boost::default_color_type node_t::* &gt;::type col = get(&amp;node_t::color, g); property_map &lt; Graph, traits::edge_descriptor node_t::* &gt;::type pred = get(&amp;node_t::predecessor, g); traits::vertex_descriptor s, t; read_dimacs_max_flow(g, capacity, rev, s, t); long flow, flow_cost; // XXX The "non-named parameter version" (works fine) flow = edmonds_karp_max_flow(g, s, t,capacity,residual_capacity,rev,col,pred); // XXX The "named parameter version" (producing errors) // flow = edmonds_karp_max_flow(g, s, t, // capacity_map(capacity) // .residual_capacity_map(residual_capacity) // .reverse_edge_map(rev) // .color_map(col) // .predecessor_map(pred)); find_flow_cost(g,capacity,residual_capacity,cost); //flow_cost = find_flow_cost(g,capacity,residual_capacity,cost); std::cout &lt;&lt; "c The total flow:" &lt;&lt; std::endl; std::cout &lt;&lt; "s " &lt;&lt; flow &lt;&lt; std::endl &lt;&lt; std::endl; std::cout &lt;&lt; "c flow values:" &lt;&lt; std::endl; graph_traits &lt; Graph &gt;::vertex_iterator u_iter, u_end; graph_traits &lt; Graph &gt;::out_edge_iterator ei, e_end; for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] &gt; 0) std::cout &lt;&lt; "a " &lt;&lt; *u_iter &lt;&lt; " " &lt;&lt; target(*ei, g) &lt;&lt; " " &lt;&lt; (capacity[*ei] - residual_capacity[*ei]) &lt;&lt; std::endl; return EXIT_SUCCESS; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11374 Trac 1.4.3 Maël Valais <mael.valais@…> Thu, 04 Jun 2015 12:30:00 GMT attachment set https://svn.boost.org/trac10/ticket/11374 https://svn.boost.org/trac10/ticket/11374 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">0001-trac-11374-fixed-find_flow_cost-where-it-was-impossi.patch</span> </li> </ul> Ticket John Maddock Fri, 12 Jun 2015 18:15:51 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11374#comment:1 https://svn.boost.org/trac10/ticket/11374#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 14:44:34 GMT <link>https://svn.boost.org/trac10/ticket/11374#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11374#comment:2</guid> <description> <p> PR added: <a class="ext-link" href="https://github.com/boostorg/graph/pull/59"><span class="icon">​</span>https://github.com/boostorg/graph/pull/59</a> </p> </description> <category>Ticket</category> </item> <item> <author>Maël Valais <mael.valais@…></author> <pubDate>Wed, 02 Mar 2016 17:08:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11374#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11374#comment:3</guid> <description> <p> Also a closely related bug: </p> <p> I wanted to use <code>find_flow_cost()</code> with the named parameter feature (as well as my bundled properties). Here is a small example that should work but doesn't: </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;bundled properties&quot; &amp; &quot;named parameters&quot; version (producing errors)</span> <span class="n">find_flow_cost</span><span class="p">(</span><span class="n">g</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">weight_map</span><span class="p">(</span><span class="n">cost</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> </description> <category>Ticket</category> </item> <item> <author>Maël Valais <mael.valais@…></author> <pubDate>Tue, 03 May 2016 08:45:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11374#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11374#comment:4</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>