c++ - 有没有办法在 boost dijkstra 算法期间减轻 IndexInHeapMap 初始化?
问题描述
上下文:我的代码使用 boost dijkstra 算法在 13.4M 顶点/33M 边图上执行寻路。在进行分析时,我注意到 60% 的 dijkstra 调用由初始化 a IndexInHeapMap
during的调用支配dijkstra_shortest_paths_no_color_map_no_init
。我怀疑由于图形大小需要很长时间
有没有办法避免/减少这种初始化成本?
也许最糟糕的是,我们的 dijkstra 调用是有上限的,并且与图大小相比并没有执行很多迭代
我查看了boost source,发现在某个时候,宏允许使用替代队列 ( BOOST_GRAPH_DIJKSTRA_USE_RELAXED_HEAP
)。但是我找不到关于它的文档,而且这部分似乎在更新的版本中被删除了(我们使用 v1.62)
我对提升 dijkstra 的确切呼吁是
boost::dijkstra_shortest_paths_no_color_map_no_init(
graph,
sourceVertex,
&(predecessors[0]),
&(distances[0]),
weights,
vertexIndex,
std::less<uint32_t>(),
boost::closed_plus<uint32_t>(),
infinity,
zero,
visitor
);
然后在boost代码里面,这个区域变得很长
typedef
detail::vertex_property_map_generator<Graph, VertexIndexMap, std::size_t>
IndexInHeapMapHelper;
typedef typename IndexInHeapMapHelper::type IndexInHeapMap;
typedef
d_ary_heap_indirect<Vertex, 4, IndexInHeapMap, DistanceMap, DistanceCompare>
VertexQueue;
boost::scoped_array<std::size_t> index_in_heap_map_holder;
IndexInHeapMap index_in_heap =
IndexInHeapMapHelper::build(graph, index_map, // <--- Take 60% of scope runtime
index_in_heap_map_holder);
VertexQueue vertex_queue(distance_map, index_in_heap, distance_compare);
解决方案
推荐阅读
- c++ - 生成范围内的随机数,其中百分比为特定值
- java - 有没有办法并行迭代嵌套列表?
- reactjs - 从 Firestore 获取数据后如何设置状态
- sharepoint - SPO & CSOM & 无法将文档上传到文档库,但我可以创建文件夹
- python - ModuleNotFoundError:没有名为“tensorflow.keras”的模块
- outlook-addin - 项目附件的不同客户端上的附件 contentType 和附件名称之间存在差异
- python-3.x - 与 return pop() 相比,pop() 返回什么?
- hibernate - 将项目添加到@OneToMany FetchType.LAZY 列表而不将列表读入内存?
- javascript - 如何存储引用 DOM 元素以供以后使用
- excel - 如何在EXCEL的条件语句中求和?