Update contrib.
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 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
11 #include <boost/config.hpp>
15 #include <boost/tuple/tuple.hpp>
16 #include <boost/graph/adjacency_list.hpp>
17 #include <boost/graph/visitors.hpp>
18 #include <boost/graph/breadth_first_search.hpp>
20 #include <boost/graph/adj_list_serialize.hpp>
21 #include <boost/archive/xml_iarchive.hpp>
22 #include <boost/archive/xml_oarchive.hpp>
25 #include "std_log_result.h"
26 #define LOG_FILENAME_LINE __FILE__, __LINE__
28 struct vertex_properties {
31 template<class Archive>
32 void serialize(Archive & ar, const unsigned int version) {
33 ar & BOOST_SERIALIZATION_NVP(name);
37 struct edge_properties {
40 template<class Archive>
41 void serialize(Archive & ar, const unsigned int version) {
42 ar & BOOST_SERIALIZATION_NVP(name);
46 using namespace boost;
48 typedef adjacency_list<vecS, vecS, undirectedS,
49 vertex_properties, edge_properties> Graph;
51 typedef graph_traits<Graph>::vertex_descriptor vd_type;
54 typedef adjacency_list<vecS, vecS, undirectedS,
55 vertex_properties> Graph_no_edge_property;
60 std::ofstream ofs("./kevin-bacon2.dat");
61 archive::xml_oarchive oa(ofs);
65 vd_type A = add_vertex( vp, g );
67 vd_type B = add_vertex( vp, g );
71 add_edge( A, B, ep, g);
73 oa << BOOST_SERIALIZATION_NVP(g);
75 Graph_no_edge_property g_n;
76 oa << BOOST_SERIALIZATION_NVP(g_n);
80 std::ifstream ifs("./kevin-bacon2.dat");
81 archive::xml_iarchive ia(ifs);
83 ia >> BOOST_SERIALIZATION_NVP(g);
85 if (!( g[*(vertices( g ).first)].name == "A" )) return -1;
87 Graph_no_edge_property g_n;
88 ia >> BOOST_SERIALIZATION_NVP(g_n);
93 std_log(LOG_FILENAME_LINE,"[End Test Case ]");
95 testResultXml("serialize");