Note that there are some explanatory texts on larger screens.

plurals
  1. POBGL dijkstra_shortest_path algorithm method does not accept my color map exterior property
    text
    copied!<p>I have been trying to get boost graph lib's dijkstra_shortest_paths to compile for about a week now without avail. I am trying to use exterior property maps for the different named parameters required by the templated method. My graph uses bundled properties for the vertex and the edges and I have been able to build the graph successfully. I will show you what I have for the code:</p> <pre><code>// vertex bundled properties struct BusStop { unsigned int id; //used for creating vertex index property map string name; Location* pLocation; }; // edge bundled properties: struct Route { string routeName; BusType type; float distance; }; </code></pre> <p>Here is my graph declaration:</p> <p><code>typedef boost::adjacency_list&lt;boost::vecS, boost::setS, boost::undirectedS, BusStop, Route&gt; BusRouteGraph;</code></p> <p>Here is my method that tries to do dijkstra's shortest path on the given graph:</p> <pre><code>template&lt;typename Graph&gt; bool shortestPathSearch(Graph&amp; g, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor src, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor dest) { bool bPathFound = false; VertexIndexMap index_map = get(&amp;BusStop::id, g); // Initialize index_map typedef typename graph_traits&lt;Graph&gt;::vertex_iterator V_Iter; V_Iter v_iter, v_iter_end; int c = 0; for( boost::tie(v_iter, v_iter_end) = vertices(g); v_iter != v_iter_end; ++v_iter, ++c) { index_map[*v_iter] = c; } // Create exterior properties for these vector&lt;int&gt; predecessor(num_vertices(g)); vector&lt;float&gt; distances(num_vertices(g), 0.0f); vector&lt;default_color_type&gt; colors(num_vertices(g)); dijkstra_shortest_paths(g, src, weight_map(get(&amp;Route::distance, g)) .color_map (make_iterator_property_map(colors.begin(), index_map)) .distance_map(make_iterator_property_map(distances.begin(), index_map))); return bPathFound; } </code></pre> <p>I get these compile time errors:(only the first error below)</p> <pre><code>\src\BusRouteFinder.cpp:461:2: instantiated from 'bool shortestPathSearch (Graph&amp;, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor) [with Graph = boost::adjacency_list&lt;boost::vecS, boost::setS, boost::undirectedS, BusStop, Route&gt;, typename boost::graph_traits&lt;Graph&gt;::vertex_descriptor = void*]' ..\src\BusRouteFinder.cpp:91:39: instantiated from here C:\boost\boost_1_48_0/boost/graph/two_bit_color_map.hpp:86:3: error: invalid cast from type 'boost::default_property_traits&lt;boost::adj_list_vertex_property_map&lt;boost::adjacency_list&lt;boost::vecS, boost::setS, boost::undirectedS, BusStop, Route&gt;, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&amp;, boost::vertex_index_t&gt; &gt;::value_type {aka boost::detail::error_property_not_found}' to type 'std::size_t {aka unsigned int}' C:\boost\boost_1_48_0/boost/graph/two_bit_color_map.hpp:88:30: error: no match for 'operator/' in 'i / elements_per_char' C:\boost\boost_1_48_0/boost/graph/two_bit_color_map.hpp:88:30: note: candidates are: C:\boost\boost_1_48_0/boost/concept_archetype.hpp:316:3: note: template&lt;class Base&gt; boost::dividable_archetype&lt;Base&gt; boost::operator/(const boost::dividable_archetype&lt;Base&gt;&amp;, const boost::dividable_archetype&lt;Base&gt;&amp;) C:\boost\boost_1_48_0/boost/concept_archetype.hpp:344:3: note: template&lt;class Return, class BaseFirst, class BaseSecond&gt; Return boost::operator/(const boost::divide_op_first_archetype&lt;Return, BaseFirst&gt;&amp;, const boost::divide_op_second_archetype&lt;Return, BaseSecond&gt;&amp;) C:\boost\boost_1_48_0/boost/graph/two_bit_color_map.hpp:89:58: error: no match for 'operator%' in 'i % elements_per_char' C:\boost\boost_1_48_0/boost/graph/two_bit_color_map.hpp:89:58: note: candidates are: C:\boost\boost_1_48_0/boost/concept_archetype.hpp:317:3: note: template&lt;class Base&gt; boost::modable_archetype&lt;Base&gt; boost::operator%(const boost::modable_archetype&lt;Base&gt;&amp;, const boost::modable_archetype&lt;Base&gt;&amp;) C:\boost\boost_1_48_0/boost/concept_archetype.hpp:346:3: note: template&lt;class Return, class BaseFirst, class BaseSecond&gt; Return boost::operator%(const boost::mod_op_first_archetype&lt;Return, BaseFirst&gt;&amp;, const boost::mod_op_second_archetype&lt;Return, BaseSecond&gt;&amp;) </code></pre> <p>I have toiled with this for a long time and I don't seem to be arriving at a solution. I thought I'd ask some one here before I give up on BGL :(</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload