Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61231 - trunk/libs/graph/example
From: jewillco_at_[hidden]
Date: 2010-04-12 16:07:27


Author: jewillco
Date: 2010-04-12 16:07:26 EDT (Mon, 12 Apr 2010)
New Revision: 61231
URL: http://svn.boost.org/trac/boost/changeset/61231

Log:
Fixed fr_layout example and added it to Jamfile
Text files modified:
   trunk/libs/graph/example/Jamfile.v2 | 1 +
   trunk/libs/graph/example/fr_layout.cpp | 14 +++++++++-----
   2 files changed, 10 insertions(+), 5 deletions(-)

Modified: trunk/libs/graph/example/Jamfile.v2
==============================================================================
--- trunk/libs/graph/example/Jamfile.v2 (original)
+++ trunk/libs/graph/example/Jamfile.v2 2010-04-12 16:07:26 EDT (Mon, 12 Apr 2010)
@@ -21,3 +21,4 @@
 exe mcgregor_subgraphs_example : mcgregor_subgraphs_example.cpp ;
 exe grid_graph_example : grid_graph_example.cpp ;
 exe bipartite_example : bipartite_example.cpp ;
+exe fr_layout : fr_layout.cpp ;

Modified: trunk/libs/graph/example/fr_layout.cpp
==============================================================================
--- trunk/libs/graph/example/fr_layout.cpp (original)
+++ trunk/libs/graph/example/fr_layout.cpp 2010-04-12 16:07:26 EDT (Mon, 12 Apr 2010)
@@ -9,7 +9,7 @@
 #include <boost/graph/fruchterman_reingold.hpp>
 #include <boost/graph/random_layout.hpp>
 #include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/simple_point.hpp>
+#include <boost/graph/topology.hpp>
 #include <boost/lexical_cast.hpp>
 #include <string>
 #include <iostream>
@@ -37,6 +37,9 @@
             << " Vertices and their positions are written to standard output with the label,\n x-position, and y-position of a vertex on each line, separated by spaces.\n";
 }
 
+typedef boost::rectangle_topology<> topology_type;
+typedef topology_type::point_type point_type;
+
 typedef adjacency_list<listS, vecS, undirectedS,
                        property<vertex_name_t, std::string> > Graph;
 
@@ -110,7 +113,7 @@
     add_edge(get_vertex(source, g, names), get_vertex(target, g, names), g);
   }
   
- typedef std::vector<simple_point<double> > PositionVec;
+ typedef std::vector<point_type> PositionVec;
   PositionVec position_vec(num_vertices(g));
   typedef iterator_property_map<PositionVec::iterator,
                                 property_map<Graph, vertex_index_t>::type>
@@ -118,15 +121,16 @@
   PositionMap position(position_vec.begin(), get(vertex_index, g));
 
   minstd_rand gen;
- random_graph_layout(g, position, -width/2, width/2, -height/2, height/2, gen);
+ topology_type topo(gen, -width/2, -height/2, width/2, height/2);
+ random_graph_layout(g, position, topo);
   fruchterman_reingold_force_directed_layout
- (g, position, width, height,
+ (g, position, topo,
      cooling(progress_cooling(iterations)));
 
   graph_traits<Graph>::vertex_iterator vi, vi_end;
   for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
     std::cout << get(vertex_name, g, *vi) << '\t'
- << position[*vi].x << '\t' << position[*vi].y << std::endl;
+ << position[*vi][0] << '\t' << position[*vi][1] << std::endl;
   }
   return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk