Search code examples
c++boostgraphboost-graph

Boost C++ - generating a layout


I've been recently dealing with graph drawing with C++. My question is, how can I fix the final error:

 required from here
/usr/include/boost/graph/random_layout.hpp:30:8: error: ‘const class boost::random::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>’ has no member named ‘random_point’
     put(position_map, v, topology.random_point());
        ^

For this little code snippet:

  boost::minstd_rand gen;
  PositionVec position_vec(num_vertices(component));
  PositionMap position(position_vec.begin(), get(vertex_index, component));
  topology_type topo(gen, -width/2, -height/2, width/2, height/2);
  boost::random_graph_layout(component, position, gen);

What am I doing wrong here?

Thank you very much.


Solution

  • According to reference

    template<typename Graph, typename PositionMap, typename Topology>
    void
    random_graph_layout(const Graph& g, PositionMap position_map,
                    const Topology& space);  // <---
    

    you should pass as third parameter of random_graph_layout Topology object not generator.

    So call

    boost::random_graph_layout(component, position, topo);