19 template<
typename Graph,
typename VertexIndexMap,
typename EdgeIndexMap>
21 write_graphio_graph(std::ostream & out,
const Graph & g,
22 VertexIndexMap vertex_index_map, EdgeIndexMap edge_index_map)
25 typename boost::graph_traits<Graph>::vertex_iterator vi, vi_end;
26 for (boost::tie(vi,vi_end)=vertices(g); vi!=vi_end; ++vi)
28 std::size_t index =
get(vertex_index_map, *vi);
29 out <<
"vertex " << index <<
"\n";
33 typename boost::graph_traits<Graph>::edge_iterator ei, ei_end;
34 for (boost::tie(ei,ei_end)=edges(g); ei!=ei_end; ++ei)
36 std::size_t index =
get(edge_index_map, *ei);
37 out <<
"edge " << index
38 <<
" source " << boost::source(*ei, g)
39 <<
" target " << boost::target(*ei, g)
50 template<
typename Graph,
typename VertexIndexMap,
typename EdgeIndexMap>
52 write_graphio_properties(std::ostream & out,
const Graph & g,
53 VertexIndexMap vertex_index_map, EdgeIndexMap edge_index_map,
54 boost::dynamic_properties & properties)
56 boost::dynamic_properties::iterator it;
57 for (it=properties.begin(); it!=properties.end(); it++)
59 if (it->second->value() !=
typeid(std::string))
60 throw std::runtime_error(
"a property map is not string-valued!");
61 if (it->second->key() ==
typeid(
typename boost::graph_traits<Graph>::vertex_descriptor))
63 typename boost::graph_traits<Graph>::vertex_iterator vi, vi_end;
64 for (boost::tie(vi,vi_end)=vertices(g); vi!=vi_end; ++vi)
66 std::size_t index =
get(vertex_index_map, *vi);
67 std::string value = boost::any_cast<std::string>(it->second->get(*vi));
68 out <<
"vprop " << index <<
" " << it->first <<
" " << value <<
"\n";
71 else if (it->second->key() ==
typeid(
typename boost::graph_traits<Graph>::edge_descriptor))
73 typename boost::graph_traits<Graph>::edge_iterator ei, ei_end;
74 for (boost::tie(ei,ei_end)=edges(g); ei!=ei_end; ++ei)
76 std::size_t index =
get(edge_index_map, *ei);
77 std::string value = boost::any_cast<std::string>(it->second->get(*ei));
78 out <<
"eprop " << index <<
" " << it->first <<
" " << value <<
"\n";
82 throw std::runtime_error(
"a property map is not vertex-keyed or edge-keyed!");
87 void load_properties(std::istream & is)
90 while (std::getline(is,str))
104 typename std::map<std::string, IOBaseEdge>::iterator found = edge_serializers.find(tag);
105 if (found == edge_serializers.end())
108 found->second->deserialize(edge_vector_map[index], ss);