Boost logo

Boost Users :

Subject: [Boost-users] Trouble w/ fruchterman-reingold
From: eric (eric.burns_at_[hidden])
Date: 2012-10-03 16:43:25


I'm seeing a weird problem in fruchterman_reingold.hpp that after the
displacements are calculated for every vertex, it gets down to the loop
where it updates the positions (starting on line 327), and all the
displacements are (0,0) by that point (they had been sensible values up in
the calculation loop). Any idea what I could be doing to cause that? Here
is my code:

struct spring_attractive_force {
  template<typename Graph, typename T>
  T
  operator()(typename graph_traits<Graph>::edge_descriptor,
             T k,
             T d,
             const Graph&) const
  {
    return d;
  }
};

struct magnetic_repulsive_force {
  template<typename Graph, typename T>
  T
  operator()(typename graph_traits<Graph>::vertex_descriptor,
             typename graph_traits<Graph>::vertex_descriptor,
             T k,
             T d,
             const Graph&) const
  {
    return 1 / (d * d);
  }
};

        typedef adjacency_list<listS, listS, undirectedS,
                                 // Vertex properties
                                 property&lt;vertex_index_t, int,
                                 property&lt;vertex_position_t, point> >,
                                 // Edge properties
                                 property<edge_weight_t, double> > Graph;
        enum {A, B, C, D, E, F, G, H};
        simple_edge triangular_edges[14] = {
                {A, B}, {B, C}, {C, A},
                {D, E}, {E, F}, {F, G}, {G, H}, {H, D},
                {D, F}, {F, H}, {H, E}, {E, G}, {G, D}
        };

        Graph g(&triangular_edges[0], &triangular_edges[13], 8);

        // Generate (x,y) coordinates for every node
        
        // - Randomly layout vertices of graph

        minstd_rand gen;
        rectangle_topology<> rect_top(gen, -25, -25, 25, 25);
        random_graph_layout(g, get(vertex_position, g), rect_top);

        // - Run Fruchterman Reingold algorithm on them

        typedef square_topology<> Topology;
        Topology topology(gen, 50.0);
        fruchterman_reingold_force_directed_layout(g, get(vertex_position, g),
topology,
                                attractive_force(spring_attractive_force()).
                                repulsive_force(magnetic_repulsive_force()).
                                force_pairs(all_force_pairs()).
                                cooling(linear_cooling<double>(100)));

--
View this message in context: http://boost.2283326.n4.nabble.com/Trouble-w-fruchterman-reingold-tp4636494.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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