12 #ifndef ADJ_LIST_SERIALIZE_HPP 
   13 #define ADJ_LIST_SERIALIZE_HPP 
   15 #include <boost/graph/adjacency_list.hpp> 
   16 #include <boost/graph/iteration_macros.hpp> 
   17 #include <boost/pending/property_serialize.hpp> 
   18 #include <boost/config.hpp> 
   19 #include <boost/detail/workaround.hpp> 
   21 #include <boost/serialization/collections_save_imp.hpp> 
   22 #include <boost/serialization/collections_load_imp.hpp> 
   23 #include <boost/serialization/split_free.hpp> 
   27 namespace serialization {
 
   31 template<
class OEL, 
class VL, 
class D, 
class VP, 
class EP, 
class GP, 
class EL>
 
   32 struct tracking_level<
boost::adjacency_list<OEL,VL,D,VP,EP,GP,EL> > {
 
   33   typedef mpl::integral_c_tag tag;
 
   34   typedef mpl::int_<track_never> type;
 
   35   BOOST_STATIC_CONSTANT(
int, value = tracking_level::type::value);
 
   38 template<
class Archive, 
class OEL, 
class VL, 
class D, 
 
   39      class VP, 
class EP, 
class GP, 
class EL>
 
   42     const boost::adjacency_list<OEL,VL,D,VP,EP,GP,EL> &graph,
 
   45   typedef adjacency_list<OEL,VL,D,VP,EP,GP,EL> Graph;
 
   46   typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
 
   48   int V = num_vertices(graph);
 
   49   int E = num_edges(graph);
 
   50   ar << BOOST_SERIALIZATION_NVP(V);
 
   51   ar << BOOST_SERIALIZATION_NVP(E);
 
   54   std::map<Vertex,int> indices;
 
   56   BGL_FORALL_VERTICES_T(v, graph, Graph) {
 
   58     ar << serialization::make_nvp(
"vertex_property", 
get(vertex_all_t(), graph, v) );
 
   62   BGL_FORALL_EDGES_T(e, graph, Graph) {
 
   63     ar << serialization::make_nvp(
"u" , indices[source(e,graph)]);
 
   64     ar << serialization::make_nvp(
"v" , indices[target(e,graph)]);
 
   65     ar << serialization::make_nvp(
"edge_property", 
get(edge_all_t(), graph, e) );
 
   68   ar << serialization::make_nvp(
"graph_property", get_property(graph, graph_all_t()) );
 
   72 template<
class Archive, 
class OEL, 
class VL, 
class D,
 
   73      class VP, 
class EP, 
class GP, 
class EL>
 
   76     boost::adjacency_list<OEL,VL,D,VP,EP,GP,EL> &graph,
 
   79   typedef adjacency_list<OEL,VL,D,VP,EP,GP,EL> Graph;
 
   80   typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
 
   81   typedef typename graph_traits<Graph>::edge_descriptor Edge;
 
   84   ar >> BOOST_SERIALIZATION_NVP(V);
 
   86   ar >> BOOST_SERIALIZATION_NVP(E);
 
   92   std::vector<Vertex> verts(V);
 
   95     Vertex v = add_vertex(graph);
 
   97     ar >> serialization::make_nvp(
"vertex_property", 
get(vertex_all_t(), graph, v) );
 
  101     ar >> BOOST_SERIALIZATION_NVP(u);
 
  102     ar >> BOOST_SERIALIZATION_NVP(v);
 
  103     Edge e; 
bool inserted;
 
  104     boost::tie(e,inserted) = add_edge(verts[u], verts[v], graph);
 
  105     ar >> serialization::make_nvp(
"edge_property", 
get(edge_all_t(), graph, e) );
 
  107   ar >> serialization::make_nvp(
"graph_property", get_property(graph, graph_all_t()) );
 
  110 template<
class Archive, 
class OEL, 
class VL, 
class D, 
class VP, 
class EP, 
class GP, 
class EL>
 
  111 inline void serialize(
 
  113     boost::adjacency_list<OEL,VL,D,VP,EP,GP,EL> &graph,
 
  114     const unsigned int file_version
 
  116     boost::serialization::split_free(ar, graph, file_version);
 
  123 #endif // ADJ_LIST_SERIALIZE_HPP