Update of /cvsroot/boost/boost/libs/graph/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12490/libs/graph/test
Modified Files:
serialize.cpp
Log Message:
Adjacency list serialization fixes, from David Keller
Index: serialize.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/graph/test/serialize.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- serialize.cpp 21 Sep 2006 17:02:14 -0000 1.2
+++ serialize.cpp 29 Jan 2007 19:54:47 -0000 1.3
@@ -8,15 +8,15 @@
#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>
+#include <boost/archive/xml_iarchive.hpp>
+#include <boost/archive/xml_oarchive.hpp>
struct vertex_properties {
std::string name;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
- ar & name;
+ ar & BOOST_SERIALIZATION_NVP(name);
}
};
@@ -25,7 +25,7 @@
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
- ar & name;
+ ar & BOOST_SERIALIZATION_NVP(name);
}
};
@@ -34,6 +34,8 @@
typedef adjacency_list<vecS, vecS, undirectedS,
vertex_properties, edge_properties> Graph;
+typedef graph_traits<Graph>::vertex_descriptor vd_type;
+
typedef adjacency_list<vecS, vecS, undirectedS,
vertex_properties> Graph_no_edge_property;
@@ -42,22 +44,34 @@
{
{
std::ofstream ofs("./kevin-bacon2.dat");
- archive::text_oarchive oa(ofs);
+ archive::xml_oarchive oa(ofs);
Graph g;
- oa << g;
+ vertex_properties vp;
+ vp.name = "A";
+ vd_type A = add_vertex( vp, g );
+ vp.name = "B";
+ vd_type B = add_vertex( vp, g );
+
+ edge_properties ep;
+ ep.name = "a";
+ add_edge( A, B, ep, g);
+
+ oa << BOOST_SERIALIZATION_NVP(g);
Graph_no_edge_property g_n;
- oa << g_n;
+ oa << BOOST_SERIALIZATION_NVP(g_n);
}
{
std::ifstream ifs("./kevin-bacon2.dat");
- archive::text_iarchive ia(ifs);
+ archive::xml_iarchive ia(ifs);
Graph g;
- ia >> g;
+ ia >> BOOST_SERIALIZATION_NVP(g);
+
+ if (!( g[*(vertices( g ).first)].name == "A" )) return -1;
Graph_no_edge_property g_n;
- ia >> g_n;
+ ia >> BOOST_SERIALIZATION_NVP(g_n);
}
return 0;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs