Boost logo

Boost Users :

Subject: Re: [Boost-users] Getting undirected graph from directed graph discarding properties
From: Philipp Klaus Krause (pkk_at_[hidden])
Date: 2012-10-11 01:01:10


On 10.10.2012 22:15, Jeremiah Willcock wrote:
> On Wed, 10 Oct 2012, Philipp Klaus Krause wrote:
>
>> I have a directed graph that has some properties, and I want the
>> underlying undirected graph, but don't need the properties there.
>> Assuming G is the directed graph with properties, and G_sym is the
>> undirected without them, up until boost 1.50 I used:
>>
>> boost::copy_graph(G, G_sym);
>>
>> But as of boost 1.51 and 1.52 this gives an error due to the properties.
>> Is there an easy way to do what I want to do in boost, and if yes, how?
>
> Pass a vertex_copy function that does nothing to copy_graph; see the
> copy_graph documentation for details, but basically you just want a
> binary function that takes anything, returns void, and is empty.
>
> -- Jeremiah Willcock

My attempt at doing so

template <class G_t, class G2_t>
struct forget_about_the_properties
{
  typedef typename boost::graph_traits<G_t>::vertex_descriptor G_desc;
  typedef typename boost::graph_traits<G2_t>::vertex_descriptor G2_desc;

  void operator()(G_desc, G2_desc) const
  {
  }
};

.
.
.

  boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> G_sym;
  //boost::copy_graph(G, G_sym);
  boost::copy_graph(G, G_sym,
boost::vertex_copy(forget_about_the_properties<G_t,
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> >()));

results in the same error.

Philipp

g++ -pipe -ggdb -g -O2 -Wall -Wno-parentheses -I /tmp/boost_1_52_0_beta1
-I /tmp/boost_1_52_0_beta1 -I. -I. -I././support/util -I. -I
/tmp/boost_1_52_0_beta1 -I. -I.. -I./../support/util -I. -I. -c -o
SDCClospre.o SDCClospre.cc
In file included from /tmp/boost_1_52_0_beta1/boost/graph/graphviz.hpp:19:0,
                 from SDCClospre.hpp:22,
                 from SDCClospre.cc:24:
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp: In
instantiation of ‘void boost::put(const boost::put_get_helper<Reference,
PropertyMap>&, K, const V&) [with PropertyMap =
boost::vec_adj_list_vertex_all_properties_map<boost::adjacency_list<boost::vecS,
boost::vecS, boost::directedS>, boost::adjacency_list<boost::vecS,
boost::vecS, boost::directedS>*, boost::no_property,
boost::no_property&>; Reference = boost::no_property&; K = long unsigned
int; V = cfg_lospre_node]’:
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:129:9: required from
‘void boost::detail::vertex_copier<Graph1, Graph2>::operator()(const
Vertex1&, Vertex2&) const [with Vertex1 = long unsigned int; Vertex2 =
long unsigned int; Graph1 = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>; Graph2 =
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>]’
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:164:11: required from
‘static void boost::detail::copy_graph_impl<0>::apply(const Graph&,
MutableGraph&, CopyVertex, CopyEdge, Orig2CopyVertexIndexMap, IndexMap)
[with Graph = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; MutableGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>;
CopyVertex =
boost::detail::vertex_copier<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> >;
CopyEdge = boost::detail::edge_copier<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> >;
IndexMap = boost::vec_adj_list_vertex_id_map<cfg_lospre_node, long
unsigned int>; Orig2CopyVertexIndexMap =
boost::iterator_property_map<__gnu_cxx::__normal_iterator<long unsigned
int*, std::vector<long unsigned int, std::allocator<long unsigned int> >
>, boost::vec_adj_list_vertex_id_map<cfg_lospre_node, long unsigned
int>, long unsigned int, long unsigned int&>]’
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:348:5: required from
‘void boost::copy_graph(const VertexListGraph&, MutableGraph&) [with
VertexListGraph = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; MutableGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>]’
SDCCtree_dec.hpp:155:3: required from ‘void
thorup_elimination_ordering(l_t&, const G_t&) [with l_t =
std::list<unsigned int>; G_t = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>]’
SDCCtree_dec.hpp:283:3: required from ‘void
thorup_tree_decomposition(T_t&, const G_t&) [with T_t =
boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
tree_dec_lospre_node>; G_t = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>]’
SDCClospre.cc:289:68: required from here
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp:361:5:
error: no match for ‘operator=’ in ‘(&((const
boost::vec_adj_list_vertex_all_properties_map<boost::adjacency_list<boost::vecS,
boost::vecS, boost::directedS>, boost::adjacency_list<boost::vecS,
boost::vecS, boost::directedS>*, boost::no_property,
boost::no_property&>&)pa))->boost::vec_adj_list_vertex_all_properties_map<Graph,
GraphPtr, Property,
PropertyRef>::operator[]<boost::adjacency_list<boost::vecS, boost::vecS,
boost::directedS>, boost::adjacency_list<boost::vecS, boost::vecS,
boost::directedS>*, boost::no_property, boost::no_property&>(k) = v’
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp:361:5: note:
candidate is:
In file included from
/tmp/boost_1_52_0_beta1/boost/graph/graph_traits.hpp:26:0,
                 from /tmp/boost_1_52_0_beta1/boost/graph/graphviz.hpp:21,
                 from SDCClospre.hpp:22,
                 from SDCClospre.cc:24:
/tmp/boost_1_52_0_beta1/boost/pending/property.hpp:18:10: note:
boost::no_property& boost::no_property::operator=(const boost::no_property&)
/tmp/boost_1_52_0_beta1/boost/pending/property.hpp:18:10: note: no
known conversion for argument 1 from ‘const cfg_lospre_node’ to ‘const
boost::no_property&’
In file included from /tmp/boost_1_52_0_beta1/boost/graph/graphviz.hpp:19:0,
                 from SDCClospre.hpp:22,
                 from SDCClospre.cc:24:
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp: In
instantiation of ‘void boost::put(const boost::put_get_helper<Reference,
PropertyMap>&, K, const V&) [with PropertyMap =
boost::adj_list_edge_all_properties_map<boost::directed_tag,
boost::no_property, boost::no_property&, boost::no_property*, long
unsigned int>; Reference = boost::no_property&; K =
boost::detail::edge_desc_impl<boost::directed_tag, long unsigned int>; V
= float]’:
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:109:9: required from
‘void boost::detail::edge_copier<Graph1, Graph2>::operator()(const
Edge1&, Edge2&) const [with Edge1 =
boost::detail::edge_desc_impl<boost::bidirectional_tag, long unsigned
int>; Edge2 = boost::detail::edge_desc_impl<boost::directed_tag, long
unsigned int>; Graph1 = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; Graph2 =
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>]’
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:173:11: required from
‘static void boost::detail::copy_graph_impl<0>::apply(const Graph&,
MutableGraph&, CopyVertex, CopyEdge, Orig2CopyVertexIndexMap, IndexMap)
[with Graph = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; MutableGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>;
CopyVertex =
boost::detail::vertex_copier<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> >;
CopyEdge = boost::detail::edge_copier<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> >;
IndexMap = boost::vec_adj_list_vertex_id_map<cfg_lospre_node, long
unsigned int>; Orig2CopyVertexIndexMap =
boost::iterator_property_map<__gnu_cxx::__normal_iterator<long unsigned
int*, std::vector<long unsigned int, std::allocator<long unsigned int> >
>, boost::vec_adj_list_vertex_id_map<cfg_lospre_node, long unsigned
int>, long unsigned int, long unsigned int&>]’
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:348:5: required from
‘void boost::copy_graph(const VertexListGraph&, MutableGraph&) [with
VertexListGraph = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; MutableGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS>]’
SDCCtree_dec.hpp:155:3: required from ‘void
thorup_elimination_ordering(l_t&, const G_t&) [with l_t =
std::list<unsigned int>; G_t = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>]’
SDCCtree_dec.hpp:283:3: required from ‘void
thorup_tree_decomposition(T_t&, const G_t&) [with T_t =
boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
tree_dec_lospre_node>; G_t = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>]’
SDCClospre.cc:289:68: required from here
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp:361:5:
error: no match for ‘operator=’ in ‘(&((const
boost::adj_list_edge_all_properties_map<boost::directed_tag,
boost::no_property, boost::no_property&, boost::no_property*, long
unsigned int>&)pa))->boost::adj_list_edge_all_properties_map<Directed,
Property, PropRef, PropPtr, Vertex>::operator[]<boost::directed_tag,
boost::no_property, boost::no_property&, boost::no_property*, long
unsigned int>(k) = v’
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp:361:5: note:
candidate is:
In file included from
/tmp/boost_1_52_0_beta1/boost/graph/graph_traits.hpp:26:0,
                 from /tmp/boost_1_52_0_beta1/boost/graph/graphviz.hpp:21,
                 from SDCClospre.hpp:22,
                 from SDCClospre.cc:24:
/tmp/boost_1_52_0_beta1/boost/pending/property.hpp:18:10: note:
boost::no_property& boost::no_property::operator=(const boost::no_property&)
/tmp/boost_1_52_0_beta1/boost/pending/property.hpp:18:10: note: no
known conversion for argument 1 from ‘const float’ to ‘const
boost::no_property&’
In file included from /tmp/boost_1_52_0_beta1/boost/graph/graphviz.hpp:19:0,
                 from SDCClospre.hpp:22,
                 from SDCClospre.cc:24:
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp: In
instantiation of ‘void boost::put(const boost::put_get_helper<Reference,
PropertyMap>&, K, const V&) [with PropertyMap =
boost::adj_list_edge_all_properties_map<boost::undirected_tag,
boost::no_property, boost::no_property&, boost::no_property*, long
unsigned int>; Reference = boost::no_property&; K =
boost::detail::edge_desc_impl<boost::undirected_tag, long unsigned int>;
V = float]’:
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:109:9: required from
‘void boost::detail::edge_copier<Graph1, Graph2>::operator()(const
Edge1&, Edge2&) const [with Edge1 =
boost::detail::edge_desc_impl<boost::bidirectional_tag, long unsigned
int>; Edge2 = boost::detail::edge_desc_impl<boost::undirected_tag, long
unsigned int>; Graph1 = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; Graph2 =
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>]’
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:173:11: required from
‘static void boost::detail::copy_graph_impl<0>::apply(const Graph&,
MutableGraph&, CopyVertex, CopyEdge, Orig2CopyVertexIndexMap, IndexMap)
[with Graph = boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, cfg_lospre_node, float>; MutableGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>;
CopyVertex =
forget_about_the_properties<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> >;
CopyEdge = boost::detail::edge_copier<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> >;
IndexMap = boost::vec_adj_list_vertex_id_map<cfg_lospre_node, long
unsigned int>; Orig2CopyVertexIndexMap =
boost::iterator_property_map<__gnu_cxx::__normal_iterator<long unsigned
int*, std::vector<long unsigned int, std::allocator<long unsigned int> >
>, boost::vec_adj_list_vertex_id_map<cfg_lospre_node, long unsigned
int>, long unsigned int, long unsigned int&>]’
/tmp/boost_1_52_0_beta1/boost/graph/copy.hpp:373:5: required from
‘void boost::copy_graph(const VertexListGraph&, MutableGraph&, const
boost::bgl_named_params<P, T, R>&) [with VertexListGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
cfg_lospre_node, float>; MutableGraph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>; P =
forget_about_the_properties<boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>,
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> >; T
= boost::vertex_copy_t; R = boost::no_property]’
SDCCtree_dec.hpp:271:3: required from ‘void
tree_decomposition_from_elimination_ordering(T_t&, const
std::list<unsigned int>&, const G_t&) [with T_t =
boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
tree_dec_lospre_node>; G_t = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>]’
SDCCtree_dec.hpp:285:3: required from ‘void
thorup_tree_decomposition(T_t&, const G_t&) [with T_t =
boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
tree_dec_lospre_node>; G_t = boost::adjacency_list<boost::vecS,
boost::vecS, boost::bidirectionalS, cfg_lospre_node, float>]’
SDCClospre.cc:289:68: required from here
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp:361:5:
error: no match for ‘operator=’ in ‘(&((const
boost::adj_list_edge_all_properties_map<boost::undirected_tag,
boost::no_property, boost::no_property&, boost::no_property*, long
unsigned int>&)pa))->boost::adj_list_edge_all_properties_map<Directed,
Property, PropRef, PropPtr, Vertex>::operator[]<boost::undirected_tag,
boost::no_property, boost::no_property&, boost::no_property*, long
unsigned int>(k) = v’
/tmp/boost_1_52_0_beta1/boost/property_map/property_map.hpp:361:5: note:
candidate is:
In file included from
/tmp/boost_1_52_0_beta1/boost/graph/graph_traits.hpp:26:0,
                 from /tmp/boost_1_52_0_beta1/boost/graph/graphviz.hpp:21,
                 from SDCClospre.hpp:22,
                 from SDCClospre.cc:24:
/tmp/boost_1_52_0_beta1/boost/pending/property.hpp:18:10: note:
boost::no_property& boost::no_property::operator=(const boost::no_property&)
/tmp/boost_1_52_0_beta1/boost/pending/property.hpp:18:10: note: no
known conversion for argument 1 from ‘const float’ to ‘const
boost::no_property&’
make[1]: *** [SDCClospre.o] Fehler 1
make[1]: Leaving directory `/home/philipp/sdcc/src'
make: *** [sdcc-cc] Fehler 2


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net