图 | 无向 |
---|---|
属性 | 颜色, 度 |
复杂度 | 时间复杂度: 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 包含 deque 中每个顶点的起始节点。“起始顶点”的选择会对排序的质量产生重大影响。对于版本 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,印第安纳大学 (jsiek@osl.iu.edu) |