Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64080 - in sandbox/SOC/2010/graph: boost/graph libs/test
From: dbarbosa_at_[hidden]
Date: 2010-07-17 01:46:36


Author: dbarbosa
Date: 2010-07-17 01:46:35 EDT (Sat, 17 Jul 2010)
New Revision: 64080
URL: http://svn.boost.org/trac/boost/changeset/64080

Log:
Copying vertex and edge properties

Text files modified:
   sandbox/SOC/2010/graph/boost/graph/difference.hpp | 11 ++++++-----
   sandbox/SOC/2010/graph/boost/graph/intersection.hpp | 7 +++++--
   sandbox/SOC/2010/graph/boost/graph/sum.hpp | 13 +++++++++----
   sandbox/SOC/2010/graph/libs/test/test.cpp | 13 +++++++------
   4 files changed, 27 insertions(+), 17 deletions(-)

Modified: sandbox/SOC/2010/graph/boost/graph/difference.hpp
==============================================================================
--- sandbox/SOC/2010/graph/boost/graph/difference.hpp (original)
+++ sandbox/SOC/2010/graph/boost/graph/difference.hpp 2010-07-17 01:46:35 EDT (Sat, 17 Jul 2010)
@@ -15,23 +15,24 @@
 #include <utility>
 #include <boost/graph/global_vertex_mapping.hpp>
 #include <boost/graph/graph_traits.hpp>
+#include <boost/graph/copy.hpp>
 
 namespace boost {
 
   template <class VertexListGraph, class MutableGraph, class globalVertexMapping>
   void difference(const VertexListGraph& g1, const VertexListGraph& g2, globalVertexMapping m, MutableGraph& g_out)
   {
-// detail::make_vertex_copier(g_in, g_out);
-// detail::make_edge_copier(g_in, g_out);
-
     typedef typename graph_traits<VertexListGraph>::vertex_descriptor InVertex;
     typedef typename graph_traits<MutableGraph>::vertex_descriptor OutVertex;
 
+ detail::vertex_copier<VertexListGraph, MutableGraph> copy_vertex = detail::make_vertex_copier(g1, g_out);
+ detail::edge_copier<VertexListGraph, MutableGraph> copy_edge = detail::make_edge_copier(g1, g_out);
+
     // copy vertices from g1
     typename graph_traits < VertexListGraph >::vertex_iterator vi, vi_end;
     for (tie(vi, vi_end) = vertices(g1); vi != vi_end; ++vi) {
       OutVertex new_v = add_vertex(g_out);
- // copy_vertex(*vi, new_v); // -> should copy vertex properties here
+ copy_vertex(*vi, new_v);
       std::pair < typename globalVertexMapping::global_id_type, bool > id = m.get_id(g1, *vi);
       assert (id.second == true);
       m.associate(g_out, new_v, id.first);
@@ -54,7 +55,7 @@
         typename graph_traits<MutableGraph>::edge_descriptor new_e;
         bool inserted;
         boost::tie(new_e, inserted) = add_edge(out_s.first, out_t.first, g_out);
- // copy_edge(*ei, new_e); // -> should copy vertex properties here
+ copy_edge(*ei, new_e); // -> should copy vertex properties here
       }
     }
 

Modified: sandbox/SOC/2010/graph/boost/graph/intersection.hpp
==============================================================================
--- sandbox/SOC/2010/graph/boost/graph/intersection.hpp (original)
+++ sandbox/SOC/2010/graph/boost/graph/intersection.hpp 2010-07-17 01:46:35 EDT (Sat, 17 Jul 2010)
@@ -24,13 +24,16 @@
     typedef typename graph_traits<VertexListGraph>::vertex_descriptor InVertex;
     typedef typename graph_traits<MutableGraph>::vertex_descriptor OutVertex;
 
+ detail::vertex_copier<VertexListGraph, MutableGraph> copy_vertex = detail::make_vertex_copier(g1, g_out);
+ detail::edge_copier<VertexListGraph, MutableGraph> copy_edge = detail::make_edge_copier(g1, g_out);
+
     // copy vertices from (g1 intersection g2)
     typename graph_traits < VertexListGraph >::vertex_iterator vi, vi_end;
     for (tie(vi, vi_end) = vertices(g1); vi != vi_end; ++vi) {
       std::pair < InVertex, bool > v = m.find_vertex( g1, *vi, g2 ); // search for vi in g2
       if (v.second == true) { // vi is also in g2
         OutVertex new_v = add_vertex(g_out);
- // copy_vertex(*vi, new_v); // -> should copy vertex properties here
+ copy_vertex(*vi, new_v);
         std::pair < typename globalVertexMapping::global_id_type, bool > id = m.get_id(g1, *vi);
         assert (id.second == true);
         m.associate(g_out, new_v, id.first);
@@ -52,7 +55,7 @@
         typename graph_traits<MutableGraph>::edge_descriptor new_e;
         bool inserted;
         boost::tie(new_e, inserted) = add_edge(out_s.first, out_t.first, g_out);
- // copy_edge(*ei, new_e); // -> should copy vertex properties here
+ copy_edge(*ei, new_e);
       }
     }
   }

Modified: sandbox/SOC/2010/graph/boost/graph/sum.hpp
==============================================================================
--- sandbox/SOC/2010/graph/boost/graph/sum.hpp (original)
+++ sandbox/SOC/2010/graph/boost/graph/sum.hpp 2010-07-17 01:46:35 EDT (Sat, 17 Jul 2010)
@@ -24,12 +24,17 @@
     typedef typename graph_traits<MutableGraph>::vertex_descriptor OutVertex;
     typedef typename globalVertexMapping::global_id_type id_type;
 
+ detail::vertex_copier<VertexListGraph, MutableGraph>
+ copy_vertex1 = detail::make_vertex_copier(g1, g_out), copy_vertex2 = detail::make_vertex_copier(g2, g_out);
+ detail::edge_copier<VertexListGraph, MutableGraph>
+ copy_edge1 = detail::make_edge_copier(g1, g_out), copy_edge2 = detail::make_edge_copier(g2, g_out);
+
 
     typename graph_traits < VertexListGraph >::vertex_iterator vi, vi_end;
     // copy vertices from g1
     for (tie(vi, vi_end) = vertices(g1); vi != vi_end; ++vi) {
       OutVertex new_v = add_vertex(g_out);
- // copy_vertex(*vi, new_v); // -> should copy vertex properties here
+ copy_vertex1(*vi, new_v);
       std::pair < typename globalVertexMapping::global_id_type, bool > id = m.get_id(g1, *vi);
       assert (id.second == true);
       m.associate(g_out, new_v, id.first);
@@ -39,7 +44,7 @@
       std::pair < InVertex, bool > v = m.find_vertex( g2, *vi, g1 ); // search for vi in g1
       if (v.second == false) { // vi is not in g1
         OutVertex new_v = add_vertex(g_out);
- // copy_vertex(*vi, new_v); // -> should copy vertex properties here
+ copy_vertex2(*vi, new_v);
         std::pair < id_type, bool > id = m.get_id(g2, *vi);
         assert (id.second == true);
         m.associate(g_out, new_v, id.first);
@@ -57,7 +62,7 @@
       typename graph_traits<MutableGraph>::edge_descriptor new_e;
       bool inserted;
       boost::tie(new_e, inserted) = add_edge(out_s.first, out_t.first, g_out);
- // copy_edge(*ei, new_e); // -> should copy vertex properties here
+ copy_edge1(*ei, new_e);
     }
     // copy edges from g2
     for (tie(ei, ei_end) = edges(g2); ei != ei_end; ++ei) {
@@ -69,7 +74,7 @@
       typename graph_traits<MutableGraph>::edge_descriptor new_e;
       bool inserted;
       boost::tie(new_e, inserted) = add_edge(out_s.first, out_t.first, g_out);
- // copy_edge(*ei, new_e); // -> should copy vertex properties here
+ copy_edge2(*ei, new_e);
     }
   }
 

Modified: sandbox/SOC/2010/graph/libs/test/test.cpp
==============================================================================
--- sandbox/SOC/2010/graph/libs/test/test.cpp (original)
+++ sandbox/SOC/2010/graph/libs/test/test.cpp 2010-07-17 01:46:35 EDT (Sat, 17 Jul 2010)
@@ -192,11 +192,13 @@
   add_edge(w, *vertices(h2).first, h2);
   get(vertex_name, h2)[z] = 'z';
 
+ cout << "graph h1:" << endl;
   prt(h1);
+ cout << "graph h2:" << endl;
   prt(h2);
 
   Graph h_du;
- cout << "Disjoint union:" << endl;
+ cout << "Disjoint union: (h1 union h2)" << endl;
   disjoint_union(h1, h2, h_du);
   prt(h_du);
   // is there any way to clear h_du and use the same variable for all?
@@ -215,24 +217,23 @@
   for (tie(vi, vi_end) = vertices(h2); vi != vi_end; vi++)
     globalId.associate(h2, *vi, *vi);
 
+ cout << "Global id:" << endl;
   globalId.show_associations();
 
   // in this example (graph sum), it creates some parallel edges (e.g., a --> x appears twice)
   // because x and y are the considered as the same
   Graph h_s;
- cout << "Graph sum:" << endl;
+ cout << "Graph sum: (h1 + h2)" << endl;
   graph_sum(h1, h2, globalId, h_s);
   prt(h_s);
 
-
   Graph h_i;
- cout << "Graph intersection:" << endl;
+ cout << "Graph intersection: (h1 intersection h2)" << endl;
   intersection(h1, h2, globalId, h_i);
   prt(h_i);
 
-
   Graph h_diff;
- cout << "Graph difference:" << endl;
+ cout << "Graph difference: (h1 - h2)" << endl;
   difference(h1, h2, globalId, h_diff);
   prt(h_diff);
 


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