【发布时间】:2012-01-26 17:35:22
【问题描述】:
我正在尝试实现一个包含数千个节点和边的流算法,因此我需要高效的数据结构。目前我做以下事情:
结构节点:
Double Linked Array (Parents) //Edges that enter the node (basicaly a tuple that contains a pointer to the parent node and the weight, current flow of the edge
Double Linked Array (Sons) //Edges that leave the node
问题是,当我执行 BFS 时,给定一个节点 v 我需要查看 residual graph 中的边缘(基本上是您发送流的边缘的后向边缘),留下 v。因为我可以平行边我需要始终知道哪个后向边缘来自哪个前向边缘。
目前我正在通过首先处理 Sons(v) 中的所有边来解决问题,然后我定义了一个映射,它为我提供了所有这些边的目标节点 w 中的父母 (w) 的索引。因此,我得到了我存储的后向边缘并可以执行我的算法。但是,这些地图具有 log(E) 访问时间,这大大降低了我的算法速度。我应该如何解决这个问题(双链表实现为 std::vector)?
【问题讨论】:
标签: c++ data-structures graph-algorithm