如何序列化类型 boost::labeled_graph

发布于 2024-12-27 00:08:50 字数 431 浏览 5 评论 0原文

我有一个 boost:labeled_graph 对象类型,它似乎没有必要的序列化功能。

    error: ‘class boost::labeled_graph<boost::adjacency_list<boost::listS, boost::listS,
 boost::undirectedS, Space, spaceEdge, graphProperties, boost::listS>, std::basic_string<char,
 std::char_traits<char>, std::allocator<char> >, boost::defaultS>’ has no member named
 ‘serialize’

有什么方法可以将labeled_graphs序列化到文件中吗?

I've got a boost:labeled_graph object type which does not seem to have necessary functions for serialization.

    error: ‘class boost::labeled_graph<boost::adjacency_list<boost::listS, boost::listS,
 boost::undirectedS, Space, spaceEdge, graphProperties, boost::listS>, std::basic_string<char,
 std::char_traits<char>, std::allocator<char> >, boost::defaultS>’ has no member named
 ‘serialize’

Any way of serializing labeled_graphs to file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2025-01-03 00:08:50

我以前没见过,但是 labeled_graph 看起来像一个薄包装围绕着您选择的另一个图表,在本例中,您根据该错误的外观选择了 adjacency_list。通过 对序列化邻接列表提供了 boost 支持,因此看起来您可以使用 自由函数序列化 对此非常明智,有些东西 喜欢:

template<class Archive>
inline void serialize(
    Archive & ar, 
    my_grap_typedef & g, 
    const unsigned int /*file_version*/
){
  ar & g.graph()
}

I've not seen before, but labeled_graph looks like a thin wrapper around another graph of your choosing, in this case you chose adjacency_list by the looks of that error. There's boost support for serializing adjacency lists via <graph/adj_list_serialize.hpp>, so it looks like you can use the free function serializing quite sensibly with this, something like:

template<class Archive>
inline void serialize(
    Archive & ar, 
    my_grap_typedef & g, 
    const unsigned int /*file_version*/
){
  ar & g.graph()
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文