图 | 无向图 |
---|---|
属性 | 颜色,度数 |
复杂度 | 时间:O(m log(m)|V|) 其中 m = max { degree(v) | v in V } |
(1) template <class IncidenceGraph, class OutputIterator, class ColorMap, class DegreeMap> OutputIterator cuthill_mckee_ordering(const IncidenceGraph& g, typename graph_traits<IncidenceGraph>::vertex_descriptor s, OutputIterator inverse_permutation, ColorMap color, DegreeMap degree) (2) template <class VertexListGraph, class OutputIterator> OutputIterator cuthill_mckee_ordering(const VertexListGraph& g, OutputIterator inverse_permutation); template <class VertexListGraph, class OutputIterator, class VertexIndexMap> OutputIterator cuthill_mckee_ordering(const VertexListGraph& g, OutputIterator inverse_permutation, VertexIndexMap index_map); template <class VertexListGraph, class OutputIterator, class ColorMap, class DegreeMap> OutputIterator cuthill_mckee_ordering(const VertexListGraph& g, OutputIterator inverse_permutation, ColorMap color, DegreeMap degree) (3) template <class IncidenceGraph, class OutputIterator, class ColorMap, class DegreeMap> OutputIterator cuthill_mckee_ordering(const IncidenceGraph& g, std::deque< typename graph_traits<IncidenceGraph>::vertex_descriptor > vertex_queue, OutputIterator inverse_permutation, ColorMap color, DegreeMap degree)Cuthill-Mckee(和反向 Cuthill-Mckee)排序算法的目标[14, 43, 44, 45 ]是通过重新排序分配给每个顶点的索引来减少图的带宽。Cuthill-Mckee 排序算法通过局部最小化第 i 个带宽来工作。顶点基本上被分配了广度优先搜索顺序,只是在每一步中,相邻顶点按照度数递增的顺序排列在队列中。
算法的版本 1 允许用户选择“起始顶点”,版本 2 使用伪外围对启发式算法(在每个组件中)查找一个好的起始顶点,而版本 3 包含双端队列中每个顶点的起始节点。“起始顶点”的选择会对排序的质量产生重大影响。对于版本 2 和 3,find_starting_vertex将对图中的每个组件调用,从而大大增加运行时间。
算法的输出是以新顺序排列的顶点。根据您使用的输出迭代器的类型,您可以获得 Cuthill-Mckee 排序或反向 Cuthill-McKee 排序。例如,如果您使用向量的反向迭代器将输出存储到向量中,则会得到反向 Cuthill-McKee 排序。
std::vector<vertex_descriptor> inv_perm(num_vertices(G)); cuthill_mckee_ordering(G, inv_perm.rbegin(), ...);
无论哪种方式,将输出存储到向量中都会为您提供从新顺序到旧顺序的排列。
inv_perm[new_index[u]] == u
通常,您需要的是相反的排列,即从旧索引到新索引的排列。这可以用以下方法轻松计算。
for (size_type i = 0; i != inv_perm.size(); ++i) perm[old_index[inv_perm[i]]] = i;
版权所有 © 2000-2001 | Jeremy Siek,印第安纳大学 ([email protected]) |