sl@0
|
1 |
// Copyright (C) 2006 Trustees of Indiana University
|
sl@0
|
2 |
//
|
sl@0
|
3 |
// Distributed under the Boost Software License, Version 1.0.
|
sl@0
|
4 |
// (See accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
5 |
// http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
6 |
/*
|
sl@0
|
7 |
* © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
|
sl@0
|
8 |
*/
|
sl@0
|
9 |
|
sl@0
|
10 |
|
sl@0
|
11 |
#include <boost/config.hpp>
|
sl@0
|
12 |
#include <iostream>
|
sl@0
|
13 |
#include <fstream>
|
sl@0
|
14 |
#include <string>
|
sl@0
|
15 |
#include <boost/tuple/tuple.hpp>
|
sl@0
|
16 |
#include <boost/graph/adjacency_list.hpp>
|
sl@0
|
17 |
#include <boost/graph/visitors.hpp>
|
sl@0
|
18 |
#include <boost/graph/breadth_first_search.hpp>
|
sl@0
|
19 |
#include <map>
|
sl@0
|
20 |
#include <boost/graph/adj_list_serialize.hpp>
|
sl@0
|
21 |
#include <boost/archive/xml_iarchive.hpp>
|
sl@0
|
22 |
#include <boost/archive/xml_oarchive.hpp>
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifdef __SYMBIAN32__
|
sl@0
|
25 |
#include "std_log_result.h"
|
sl@0
|
26 |
#define LOG_FILENAME_LINE __FILE__, __LINE__
|
sl@0
|
27 |
#endif
|
sl@0
|
28 |
struct vertex_properties {
|
sl@0
|
29 |
std::string name;
|
sl@0
|
30 |
|
sl@0
|
31 |
template<class Archive>
|
sl@0
|
32 |
void serialize(Archive & ar, const unsigned int version) {
|
sl@0
|
33 |
ar & BOOST_SERIALIZATION_NVP(name);
|
sl@0
|
34 |
}
|
sl@0
|
35 |
};
|
sl@0
|
36 |
|
sl@0
|
37 |
struct edge_properties {
|
sl@0
|
38 |
std::string name;
|
sl@0
|
39 |
|
sl@0
|
40 |
template<class Archive>
|
sl@0
|
41 |
void serialize(Archive & ar, const unsigned int version) {
|
sl@0
|
42 |
ar & BOOST_SERIALIZATION_NVP(name);
|
sl@0
|
43 |
}
|
sl@0
|
44 |
};
|
sl@0
|
45 |
|
sl@0
|
46 |
using namespace boost;
|
sl@0
|
47 |
|
sl@0
|
48 |
typedef adjacency_list<vecS, vecS, undirectedS,
|
sl@0
|
49 |
vertex_properties, edge_properties> Graph;
|
sl@0
|
50 |
|
sl@0
|
51 |
typedef graph_traits<Graph>::vertex_descriptor vd_type;
|
sl@0
|
52 |
|
sl@0
|
53 |
|
sl@0
|
54 |
typedef adjacency_list<vecS, vecS, undirectedS,
|
sl@0
|
55 |
vertex_properties> Graph_no_edge_property;
|
sl@0
|
56 |
|
sl@0
|
57 |
int main()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
{
|
sl@0
|
60 |
std::ofstream ofs("./kevin-bacon2.dat");
|
sl@0
|
61 |
archive::xml_oarchive oa(ofs);
|
sl@0
|
62 |
Graph g;
|
sl@0
|
63 |
vertex_properties vp;
|
sl@0
|
64 |
vp.name = "A";
|
sl@0
|
65 |
vd_type A = add_vertex( vp, g );
|
sl@0
|
66 |
vp.name = "B";
|
sl@0
|
67 |
vd_type B = add_vertex( vp, g );
|
sl@0
|
68 |
|
sl@0
|
69 |
edge_properties ep;
|
sl@0
|
70 |
ep.name = "a";
|
sl@0
|
71 |
add_edge( A, B, ep, g);
|
sl@0
|
72 |
|
sl@0
|
73 |
oa << BOOST_SERIALIZATION_NVP(g);
|
sl@0
|
74 |
|
sl@0
|
75 |
Graph_no_edge_property g_n;
|
sl@0
|
76 |
oa << BOOST_SERIALIZATION_NVP(g_n);
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
{
|
sl@0
|
80 |
std::ifstream ifs("./kevin-bacon2.dat");
|
sl@0
|
81 |
archive::xml_iarchive ia(ifs);
|
sl@0
|
82 |
Graph g;
|
sl@0
|
83 |
ia >> BOOST_SERIALIZATION_NVP(g);
|
sl@0
|
84 |
|
sl@0
|
85 |
if (!( g[*(vertices( g ).first)].name == "A" )) return -1;
|
sl@0
|
86 |
|
sl@0
|
87 |
Graph_no_edge_property g_n;
|
sl@0
|
88 |
ia >> BOOST_SERIALIZATION_NVP(g_n);
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
#ifdef __SYMBIAN32__
|
sl@0
|
92 |
|
sl@0
|
93 |
std_log(LOG_FILENAME_LINE,"[End Test Case ]");
|
sl@0
|
94 |
|
sl@0
|
95 |
testResultXml("serialize");
|
sl@0
|
96 |
close_log_file();
|
sl@0
|
97 |
#endif
|
sl@0
|
98 |
return 0;
|
sl@0
|
99 |
}
|