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
{
23 template<class Archive
>
24 void serialize(Archive
& ar
, const unsigned int /*version*/) {
25 ar
& BOOST_SERIALIZATION_NVP(name
);
29 struct edge_properties
{
32 template<class Archive
>
33 void serialize(Archive
& ar
, const unsigned int /*version*/) {
34 ar
& BOOST_SERIALIZATION_NVP(name
);
38 using namespace boost
;
40 typedef adjacency_list
<vecS
, vecS
, undirectedS
,
41 vertex_properties
, edge_properties
> Graph
;
43 typedef graph_traits
<Graph
>::vertex_descriptor vd_type
;
46 typedef adjacency_list
<vecS
, vecS
, undirectedS
,
47 vertex_properties
> Graph_no_edge_property
;
52 std::ofstream
ofs("./kevin-bacon2.dat");
53 archive::xml_oarchive
oa(ofs
);
57 vd_type A
= add_vertex( vp
, g
);
59 vd_type B
= add_vertex( vp
, g
);
63 add_edge( A
, B
, ep
, g
);
65 oa
<< BOOST_SERIALIZATION_NVP(g
);
67 Graph_no_edge_property g_n
;
68 oa
<< BOOST_SERIALIZATION_NVP(g_n
);
72 std::ifstream
ifs("./kevin-bacon2.dat");
73 archive::xml_iarchive
ia(ifs
);
75 ia
>> BOOST_SERIALIZATION_NVP(g
);
77 if (!( g
[*(vertices( g
).first
)].name
== "A" )) return -1;
79 Graph_no_edge_property g_n
;
80 ia
>> BOOST_SERIALIZATION_NVP(g_n
);