My Graph
type is defined as follows:
using Graph = boost::adjacency_list<vecS, setS, directedS, State, CostType>;
where CostType
happens to be int
.
I am trying to obtain the Kamada-Kawai spring layout as follows:
template <class PointMap>
PointMap layout() const {
PointMap res;
boost::associative_property_map<PointMap> temp(res);
circle_graph_layout(g_, temp, 10.0);
// http://www.boost.org/doc/libs/1_59_0/libs/graph/doc/bundles.html
bool ok = kamada_kawai_spring_layout(
g_, temp, get(edge_bundle, g_),
square_topology<>(50.0), side_length(50.0));
(void)ok;
//boost::BOOST_CHECK(ok);
return res;
}
The compiler (gcc
version 4.8.2) complains about creating a reference to void
. I have checked that the circular layout works. What am I doing wrong in the call to kamada_kawai_spring_layout
?
Here is a partial output by gcc
:
-*- mode: compilation; default-directory: "~/SearchLib/AstarWithPolicies/" -*-
Compilation started at Tue Nov 24 22:54:48
make -k
g++ -Wall -Wextra -Werror -std=c++11 -pedantic -I ~/boost_1_59_0 -I /usr/include/cairomm-1.0/ -I /usr/include/cairo/ -I /usr/include/sigc++-2.0/ -I /usr/lib/x86_64-linux-gnu/sigc++-2.0/include/ -I /usr/include/freetype2/ -o Test Test.cpp -g -lcairo -lX11
In file included from /home/meir/boost_1_59_0/boost/graph/adjacency_list.hpp:246:0,
from Graph.h:10,
from Astar.h:5,
from Test.cpp:4:
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp: In instantiation of ‘struct boost::adj_list_any_vertex_pa::bind_<boost::vertex_index_t, boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, Pancake>’:
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:2613:12: required from ‘struct boost::detail::adj_list_choose_vertex_pa<boost::vertex_index_t, boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, Pancake>’
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:2750:12: required from ‘struct boost::adj_list_vertex_property_selector::bind_<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, Pancake, boost::vertex_index_t>’
/home/meir/boost_1_59_0/boost/graph/properties.hpp:201:12: required from ‘struct boost::detail::vertex_property_map<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::vertex_index_t>’
/home/meir/boost_1_59_0/boost/graph/properties.hpp:212:10: required from ‘struct boost::property_map<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::vertex_index_t, void>’
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:1733:5: required by substitution of ‘template<class Config, class Base, class Property> typename boost::property_map<typename Config::graph_type, Property>::const_type boost::get(Property, const boost::adj_list_helper<Config, Base>&) [with Config = boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::setS, boost::vecS, boost::directedS, Pancake, int, boost::no_property, boost::listS>::config; Base = boost::directed_graph_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>, boost::setS, boost::vecS, boost::directedS, Pancake, int, boost::no_property, boost::listS>::config>; Property = boost::vertex_index_t]’
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:618:58: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::directed_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false]’
Graph.h:106:55: required from ‘PointMap StateGraph<StateNeighbor>::layout() const [with PointMap = std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > >; StateNeighbor = StateNeighbor<Pancake>]’
Drawer.h:60:75: required from ‘Drawer<Graph>::Drawer(const Graph&) [with Graph = StateGraph<StateNeighbor<Pancake> >]’
Test.cpp:34:22: required from here
/home/meir/boost_1_59_0/boost/graph/detail/adjacency_list.hpp:2543:29: error: forming reference to void
typedef value_type& reference;
UPDATE 1: the same error occurs if I change the graph type to undirectedS
.
UPDATE 2: Thanks to the comments, this is the improved version that uses an index map:
template <class PointMap>
PointMap layout() const {
PointMap res;
boost::associative_property_map<PointMap> temp(res);
circle_graph_layout(g_, temp, 10.0);
// https://stackoverflow.com/q/33903879/2725810
// https://stackoverflow.com/a/8555715/2725810
typedef std::map<VertexDescriptor, std::size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
// http://www.boost.org/doc/libs/1_59_0/libs/graph/doc/bundles.html
kamada_kawai_spring_layout(g_, temp, get(edge_bundle, g_),
square_topology<>(50.0), side_length(50.0),
layout_tolerance<CostType>(),
CostType(1), propmapIndex);
return res;
}
This still does not satisfy gcc
though:
In file included from Graph.h:13:0,
from Astar.h:5,
from Test.cpp:4:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp: In instantiation of ‘bool boost::detail::graph::kamada_kawai_spring_layout_impl<Topology, Graph, PositionMap, WeightMap, EdgeOrSideLength, Done, VertexIndexMap, DistanceMatrix, SpringStrengthMatrix, PartialDerivativeMap>::run() [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; EdgeOrSideLength = boost::detail::graph::edge_or_side<false, double>; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; DistanceMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; SpringStrengthMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; PartialDerivativeMap = boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&>]’:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:524:20: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>, Done, typename boost::property_traits<DistanceMap>::value_type, VertexIndexMap, DistanceMatrix, SpringStrengthMatrix, PartialDerivativeMap) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; DistanceMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; SpringStrengthMatrix = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; PartialDerivativeMap = boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&>; typename boost::property_traits<DistanceMap>::value_type = int]’
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:559:79: required from ‘bool boost::kamada_kawai_spring_layout(const Graph&, PositionMap, WeightMap, const Topology&, boost::detail::graph::edge_or_side<EdgeOrSideLength, T>, Done, typename boost::property_traits<DistanceMap>::value_type, VertexIndexMap) [with Topology = boost::square_topology<>; Graph = boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>; PositionMap = boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >; WeightMap = boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>; T = double; bool EdgeOrSideLength = false; Done = boost::layout_tolerance<int>; VertexIndexMap = boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >; typename boost::property_traits<DistanceMap>::value_type = int]’
Graph.h:112:61: required from ‘PointMap StateGraph<StateNeighbor>::layout() const [with PointMap = std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > >; StateNeighbor = StateNeighbor<Pancake>]’
Drawer.h:60:75: required from ‘Drawer<Graph>::Drawer(const Graph&) [with Graph = StateGraph<StateNeighbor<Pancake> >]’
Test.cpp:34:22: required from here
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: error: no matching function for call to ‘boost::detail::graph::linear_solver<2ul>::solve(boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::weight_type [2][2], boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::deriv_type&)’
_difference_type delta = -linear_solver<Point::dimensions>::solve(dE_d_d, dE_d);
^
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: note: candidate is:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:95:18: note: template<class Vec> static Vec boost::detail::graph::linear_solver<2ul>::solve(double (*)[2], Vec)
static Vec solve(double mat[2][2], Vec rhs) {
^
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:95:18: note: template argument deduction/substitution failed:
/home/meir/boost_1_59_0/boost/graph/kamada_kawai_spring_layout.hpp:313:96: note: cannot convert ‘dE_d_d’ (type ‘boost::detail::graph::kamada_kawai_spring_layout_impl<boost::square_topology<>, boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, Pancake, int, boost::no_property, boost::listS>, boost::associative_property_map<std::map<void*, boost::convex_topology<2ul>::point, std::less<void*>, std::allocator<std::pair<void* const, boost::convex_topology<2ul>::point> > > >, boost::adj_list_edge_property_map<boost::undirected_tag, int, const int&, void*, const int, boost::edge_bundle_t>, boost::detail::graph::edge_or_side<false, double>, boost::layout_tolerance<int>, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::convex_topology<2ul>::point_difference*, std::vector<boost::convex_topology<2ul>::point_difference, std::allocator<boost::convex_topology<2ul>::point_difference> > >, boost::associative_property_map<std::map<void*, long unsigned int, std::less<void*>, std::allocator<std::pair<void* const, long unsigned int> > > >, boost::convex_topology<2ul>::point_difference, boost::convex_topology<2ul>::point_difference&> >::weight_type [2][2] {aka int [2][2]}’) to type ‘double (*)[2]’
_difference_type delta = -linear_solver<Point::dimensions>::solve(dE_d_d, dE_d);
EDIT: Since this has become a different question, I started a new question here.