读取图形可视化的点文件,而无需在提升图中存储节点 ID
read dot file for graphviz without storing node-id in boost graph
我有一个名为"test.dot"的文件,如下所示:
graph {
0;
1;
0 -- 1;
}
//EOF
我想使用提升图库读取文件。
#include <boost/graph/graphviz.hpp>
using namespace std;
using namespace boost;
int main(int,char*[])
{
typedef adjacency_list< vecS, vecS, undirectedS, property<vertex_color_t,int> > Graph;
Graph g(0);
dynamic_properties dp;
auto index = get(vertex_color, g);
dp.property("node_id", index);
ifstream fin("test.dot");
read_graphviz(fin, g, dp);
}
但是,在此源代码中,我必须附加另一个属性(vertex_color_t)来存储"node_id"。在我的简单示例中,它与"node_index"相同。
有没有办法识别它们以节省内存?我不想介绍额外的属性。
dynamic_properties
有一个构造函数,它接受一个函子来处理默认情况,一个实现是boost::ignore_other_properties
。这有效:
#include <boost/graph/graphviz.hpp>
using namespace std;
using namespace boost;
int main(int,char*[])
{
typedef adjacency_list< vecS, vecS, undirectedS > Graph;
Graph g(0);
dynamic_properties dp(ignore_other_properties);
ifstream fin("test.dot");
read_graphviz(fin, g, dp);
}
相关文章:
- 反向给定链表中的K节点
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- Boost Graph Library,修复节点大小
- C++A*算法并不总是在路径中具有目标节点
- 如何找到2个单链表的公共节点
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 为什么我的删除节点函数实际上没有删除节点?
- 从函数角度看ID到文件路径的内部与外部映射
- 通过组合不同的类型来创建唯一的id
- 我们可以删除链表中静态内存中的节点吗
- 如何在pugixml中获取节点的内部XML
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- FFMPEG配置文件级别id大小无效
- 方法内部但循环仍得到预期的不合格id错误C++
- 为什么我们要为avl树实现返回一个指向节点的指针,而不是void函数
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- C ,使用ID删除节点
- 读取图形可视化的点文件,而无需在提升图中存储节点 ID
- 具有可移动节点、可访问属性和可靠ID的C++图
- 如何在 NS2 中查找节点 ID