1 // Copyright (C) 2006 Trustees of Indiana University
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #include <boost/config.hpp>
11 #include <boost/tuple/tuple.hpp>
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/graph/visitors.hpp>
14 #include <boost/graph/breadth_first_search.hpp>
16 #include <boost/graph/adj_list_serialize.hpp>
17 #include <boost/archive/xml_iarchive.hpp>
18 #include <boost/archive/xml_oarchive.hpp>
20 struct vertex_properties
24 template < class Archive
>
25 void serialize(Archive
& ar
, const unsigned int /*version*/)
27 ar
& BOOST_SERIALIZATION_NVP(name
);
31 struct edge_properties
35 template < class Archive
>
36 void serialize(Archive
& ar
, const unsigned int /*version*/)
38 ar
& BOOST_SERIALIZATION_NVP(name
);
42 using namespace boost
;
44 typedef adjacency_list
< vecS
, vecS
, undirectedS
, vertex_properties
,
48 typedef graph_traits
< Graph
>::vertex_descriptor vd_type
;
50 typedef adjacency_list
< vecS
, vecS
, undirectedS
, vertex_properties
>
51 Graph_no_edge_property
;
56 std::ofstream
ofs("./kevin-bacon2.dat");
57 archive::xml_oarchive
oa(ofs
);
61 vd_type A
= add_vertex(vp
, g
);
63 vd_type B
= add_vertex(vp
, g
);
67 add_edge(A
, B
, ep
, g
);
69 oa
<< BOOST_SERIALIZATION_NVP(g
);
71 Graph_no_edge_property g_n
;
72 oa
<< BOOST_SERIALIZATION_NVP(g_n
);
76 std::ifstream
ifs("./kevin-bacon2.dat");
77 archive::xml_iarchive
ia(ifs
);
79 ia
>> BOOST_SERIALIZATION_NVP(g
);
81 if (!(g
[*(vertices(g
).first
)].name
== "A"))
84 Graph_no_edge_property g_n
;
85 ia
>> BOOST_SERIALIZATION_NVP(g_n
);