Opened 9 years ago
#9730 new Bugs
copy_graph doesn't use graph_traits
Reported by: | Owned by: | Jeremiah Willcock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | graph |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
copy_graph doesn't use graph_traits internally. Therefore, classes which don't have traversal_category and directed_category, such as std::vector or SGB, are not used as the source graph.
follow code is compile error:
#include <vector> #include <list> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/vector_as_graph.hpp> #include <boost/graph/copy.hpp> int main() { using VectorGraph = std::vector<std::list<int>>; auto vgraph = VectorGraph{{1, 2, 3}, {3, 5}, {5}, {4}, {0, 2}, {0}}; using Graph = boost::adjacency_list<>; auto graph = Graph{}; boost::copy_graph(vgraph, graph , boost::vertex_copy([]( boost::graph_traits<VectorGraph>::vertex_descriptor , boost::graph_traits<Graph>::vertex_descriptor) {}) . edge_copy([]( boost::graph_traits<VectorGraph>::edge_descriptor , boost::graph_traits<Graph>::edge_descriptor) {}) ); }
patch is here
--- /usr/local/include/boost/graph/copy.hpp 2014-03-02 21:44:55.000000000 +0900 +++ copy.hpp 2014-03-02 21:45:05.000000000 +0900 @@ -248,8 +248,8 @@ template <class Graph> struct choose_graph_copy { - typedef typename Graph::traversal_category Trv; - typedef typename Graph::directed_category Dr; + typedef typename graph_traits<Graph>::traversal_category Trv; + typedef typename graph_traits<Graph>::directed_category Dr; enum { algo = (is_convertible<Trv, vertex_list_graph_tag>::value && is_convertible<Trv, edge_list_graph_tag>::value)
Note:
See TracTickets
for help on using tickets.