x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
disjoint_sets.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\pending\detail\disjoint_sets.hpp
旋转
特效
属性
历史版本
// (C) Copyright Jeremy Siek 2004 // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_DETAIL_DISJOINT_SETS_HPP #define BOOST_DETAIL_DISJOINT_SETS_HPP namespace boost { namespace detail { template
Vertex find_representative_with_path_halving(ParentPA p, Vertex v) { Vertex parent = get(p, v); Vertex grandparent = get(p, parent); while (parent != grandparent) { put(p, v, grandparent); v = grandparent; parent = get(p, v); grandparent = get(p, parent); } return parent; } template
Vertex find_representative_with_full_compression(ParentPA parent, Vertex v) { Vertex old = v; Vertex ancestor = get(parent, v); while (ancestor != v) { v = ancestor; ancestor = get(parent, v); } v = get(parent, old); while (ancestor != v) { put(parent, old, ancestor); old = v; v = get(parent, old); } return ancestor; } /* the postcondition of link sets is: component_representative(i) == component_representative(j) */ template
inline void link_sets(ParentPA p, RankPA rank, Vertex i, Vertex j, ComponentRepresentative comp_rep) { i = comp_rep(p, i); j = comp_rep(p, j); if (i == j) return; if (get(rank, i) > get(rank, j)) put(p, j, i); else { put(p, i, j); if (get(rank, i) == get(rank, j)) put(rank, j, get(rank, j) + 1); } } // normalize components has the following postcondidition: // i >= p[i] // that is, the representative is the node with the smallest index in its class // as its precondition it it assumes that the node container is compressed template
inline void normalize_node(ParentPA p, Vertex i) { if (i > get(p,i) || get(p, get(p,i)) != get(p,i)) put(p,i, get(p, get(p,i))); else { put(p, get(p,i), i); put(p, i, i); } } } // namespace detail } // namespace boost #endif // BOOST_DETAIL_DISJOINT_SETS_HPP
disjoint_sets.hpp
网页地址
文件地址
上一页 1/3
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.