graph/test/serialize.cpp
Douglas Gregor e505bf99db Test and fix serialization code
[SVN r35257]
2006-09-21 17:02:14 +00:00

64 lines
1.3 KiB
C++

#include <boost/config.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <boost/tuple/tuple.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <map>
#include <boost/graph/adj_list_serialize.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
struct vertex_properties {
std::string name;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & name;
}
};
struct edge_properties {
std::string name;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & name;
}
};
using namespace boost;
typedef adjacency_list<vecS, vecS, undirectedS,
vertex_properties, edge_properties> Graph;
typedef adjacency_list<vecS, vecS, undirectedS,
vertex_properties> Graph_no_edge_property;
int main()
{
{
std::ofstream ofs("./kevin-bacon2.dat");
archive::text_oarchive oa(ofs);
Graph g;
oa << g;
Graph_no_edge_property g_n;
oa << g_n;
}
{
std::ifstream ifs("./kevin-bacon2.dat");
archive::text_iarchive ia(ifs);
Graph g;
ia >> g;
Graph_no_edge_property g_n;
ia >> g_n;
}
return 0;
}