- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下代码将图形保存到 graphml 文件中。有用!。但是当我替换 typedef adjacency_list< vecS, vecS, directedS,
时与 typedef adjacency_list< setS, setS, directedS,
这样就没有重复的顶点或边被插入到图中,它提示道。
#include <boost/graph/graphml.hpp>
using namespace std;
typedef struct {
string name;
string label;
} vertex_type_t;
int main(int,char*[])
{
using namespace boost;
typedef adjacency_list< vecS, vecS, directedS,
vertex_type_t > graph_t;
graph_t g;
graph_t::vertex_descriptor v1 = add_vertex(g);
graph_t::vertex_descriptor v2 = add_vertex(g);
dynamic_properties dp;
dp.property("name", get(&vertex_type_t::name, g));
write_graphml(std::cout, g, dp, true);
return 0;
}
我无法从错误中获益。我认为以下是主要错误。
/usr/include/boost/graph/graphml.hpp: In function ‘void boost::write_graphml(std::ostream&, const Graph&, VertexIndexMap, const boost::dynamic_properties&, bool) [with Graph = boost::adjacency_list<boost::setS, boost::setS, boost::directedS, vertex_type_t>, VertexIndexMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::setS, boost::setS, boost::directedS, vertex_type_t>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t>, std::ostream = std::basic_ostream<char>]’:
/usr/include/boost/graph/graphml.hpp:345:5: instantiated from ‘void boost::write_graphml(std::ostream&, const Graph&, const boost::dynamic_properties&, bool) [with Graph = boost::adjacency_list<boost::setS, boost::setS, boost::directedS, vertex_type_t>, std::ostream = std::basic_ostream<char>]’
write_graphviz.cpp:24:39: instantiated from here
/usr/include/boost/graph/graphml.hpp:301:9: error: no match for ‘operator<<’ in ‘std::operator<< [with _Traits = std::char_traits<char>]((* & out), ((const char*)" <node id=\"n")) << boost::get [with PropertyMap = boost::adj_list_vertex_property_map<boost::adjacency_list<boost::setS, boost::setS, boost::directedS, vertex_type_t>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t>, Reference = const boost::detail::error_property_not_found&, K = void*]((*(const boost::put_get_helper<const boost::detail::error_property_not_found&, boost::adj_list_vertex_property_map<boost::adjacency_list<boost::setS, boost::setS, boost::directedS, vertex_type_t>, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t> >*)(& vertex_index)), (* & v.std::_Rb_tree_const_iterator<_Tp>::operator* [with _Tp = void*, std::_Rb_tree_const_iterator<_Tp>::reference = void* const&]()))’
/usr/include/boost/graph/graphml.hpp:301:9: note: candidates are:
/usr/include/c++/4.6/ostream:110:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
/usr/include/c++/4.6/ostream:110:7: note: no known conversion for argument 1 from ‘const boost::detail::error_property_not_found’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&)}’
/usr/include/c++/4.6/ostream:119:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
我真的很想使用 setS 作为边缘容器。我不确定如何修改此程序以使其开始工作,因为错误消息对我来说意义不大。
最佳答案
问题是 write_graphml
在你的图表中需要一个 VertexIndexMap 并且只有 adjacency_list
和 VertexList=vecS
默认创建一个。如果您使用 listS
或 setS
,则必须自己创建一个。
I really want to use setS as edge containers.
如果你只需要在你的OutEdgeList
中使用setS
,你可以简单地使用:
typedef adjacency_list< setS, vecS, directedS,
vertex_type_t > graph_t;
如果你必须对两者都使用 setS
那么你的程序应该是(基于 this answer ):
#include <boost/graph/graphml.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <map>
using namespace std;
typedef struct
{
string name;
string label;
} vertex_type_t;
int main ( int, char*[] )
{
using namespace boost;
typedef adjacency_list < setS, vecS, directedS,
vertex_type_t > graph_t;
typedef graph_t::vertex_descriptor NodeID; //define your Vertex Index Map
typedef std::map<NodeID, size_t> IndexMap;
IndexMap mapIndex;
boost::associative_property_map<IndexMap> propmapIndex ( mapIndex );
graph_t g;
graph_t::vertex_descriptor v1 = add_vertex ( g );
graph_t::vertex_descriptor v2 = add_vertex ( g );
int i = 0; //fill your Vertex Index Map
BGL_FORALL_VERTICES ( v, g, graph_t )
{
put ( propmapIndex, v, i++ );
}
g[v1].name="FirstVertex";
g[v2].name="SecondVertex";
dynamic_properties dp;
dp.property ( "name", get ( &vertex_type_t::name, g ) );
write_graphml ( std::cout, g, propmapIndex, dp, true );
return 0;
}
关于c++ - 使用boost将非平行边图保存到graphml文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12887008/
这个问题在这里已经有了答案: Can I get `cabal install` to use multiple cores? (3 个回答) 关闭 7 年前。 在使用类似于 GNU make 的 -
我正在尝试通过 akeeba backup 在 parallels plesk 面板中安装一个 joomla 站点。我在哪里面临文件权限问题。 An error occured Could not o
我在 MATLAB 中使用箱线图函数。我需要为 6 个“XTicks”绘制 6 个不同数据集的箱线图,即 x 轴上的每个刻度线应包含 6 个相应的框、晶须、中线和其域内的异常值集。我尝试通过为每个变量
我需要在 Kaplan Meier 图上呈现 at_risk 数字。 最终结果应该与此类似: 我在渲染时遇到的问题是 No。处于危险中的患者数量位于图表底部。此处显示的值对应于 x 轴上的值。因此本质
我想知道你们中的任何一个人为什么知道我的表现糟透了吗? 我正在努力实现的目标; 生成220万个文件。要创建每个文件,平均需要2-5个数据库调用。 我正在使用的服务器具有24个内核和190GB的RAM。
请帮忙。我正在研究具有此要求的算法。 给定 4 个“右”矩形(右矩形的边平行于 x 或 y),找出它们中的任何一个覆盖的区域 例如,灰色区域被下图中的 4 个矩形中的任何一个覆盖。 enter ima
我是一名优秀的程序员,十分优秀!