x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
bc_clustering.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\graph\bc_clustering.hpp
旋转
特效
属性
历史版本
// Copyright 2004 The Trustees of Indiana University. // 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) // Authors: Douglas Gregor // Andrew Lumsdaine #ifndef BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP #define BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP #include
#include
#include
#include
#include
#include
namespace boost { /** Threshold termination function for the betweenness centrality * clustering algorithm. */ template
struct bc_clustering_threshold { typedef T centrality_type; /// Terminate clustering when maximum absolute edge centrality is /// below the given threshold. explicit bc_clustering_threshold(T threshold) : threshold(threshold), dividend(1.0) {} /** * Terminate clustering when the maximum edge centrality is below * the given threshold. * * @param threshold the threshold value * * @param g the graph on which the threshold will be calculated * * @param normalize when true, the threshold is compared against the * normalized edge centrality based on the input graph; otherwise, * the threshold is compared against the absolute edge centrality. */ template
bc_clustering_threshold(T threshold, const Graph& g, bool normalize = true) : threshold(threshold), dividend(1.0) { if (normalize) { typename graph_traits
::vertices_size_type n = num_vertices(g); dividend = T((n - 1) * (n - 2)) / T(2); } } /** Returns true when the given maximum edge centrality (potentially * normalized) falls below the threshold. */ template
bool operator()(T max_centrality, Edge, const Graph&) { return (max_centrality / dividend) < threshold; } protected: T threshold; T dividend; }; /** Graph clustering based on edge betweenness centrality. * * This algorithm implements graph clustering based on edge * betweenness centrality. It is an iterative algorithm, where in each * step it compute the edge betweenness centrality (via @ref * brandes_betweenness_centrality) and removes the edge with the * maximum betweenness centrality. The @p done function object * determines when the algorithm terminates (the edge found when the * algorithm terminates will not be removed). * * @param g The graph on which clustering will be performed. The type * of this parameter (@c MutableGraph) must be a model of the * VertexListGraph, IncidenceGraph, EdgeListGraph, and Mutable Graph * concepts. * * @param done The function object that indicates termination of the * algorithm. It must be a ternary function object thats accepts the * maximum centrality, the descriptor of the edge that will be * removed, and the graph @p g. * * @param edge_centrality (UTIL/OUT) The property map that will store * the betweenness centrality for each edge. When the algorithm * terminates, it will contain the edge centralities for the * graph. The type of this property map must model the * ReadWritePropertyMap concept. Defaults to an @c * iterator_property_map whose value type is * @c Done::centrality_type and using @c get(edge_index, g) for the * index map. * * @param vertex_index (IN) The property map that maps vertices to * indices in the range @c [0, num_vertices(g)). This type of this * property map must model the ReadablePropertyMap concept and its * value type must be an integral type. Defaults to * @c get(vertex_index, g). */ template
void betweenness_centrality_clustering(MutableGraph& g, Done done, EdgeCentralityMap edge_centrality, VertexIndexMap vertex_index) { typedef typename property_traits
::value_type centrality_type; typedef typename graph_traits
::edge_iterator edge_iterator; typedef typename graph_traits
::edge_descriptor edge_descriptor; typedef typename graph_traits
::vertices_size_type vertices_size_type; if (edges(g).first == edges(g).second) return; // Function object that compares the centrality of edges indirect_cmp
> cmp(edge_centrality); bool is_done; do { brandes_betweenness_centrality(g, edge_centrality_map(edge_centrality) .vertex_index_map(vertex_index)); edge_descriptor e = *max_element(edges(g).first, edges(g).second, cmp); is_done = done(get(edge_centrality, e), e, g); if (!is_done) remove_edge(e, g); } while (!is_done && edges(g).first != edges(g).second); } /** * \overload */ template
void betweenness_centrality_clustering(MutableGraph& g, Done done, EdgeCentralityMap edge_centrality) { betweenness_centrality_clustering(g, done, edge_centrality, get(vertex_index, g)); } /** * \overload */ template
void betweenness_centrality_clustering(MutableGraph& g, Done done) { typedef typename Done::centrality_type centrality_type; std::vector
edge_centrality(num_edges(g)); betweenness_centrality_clustering(g, done, make_iterator_property_map(edge_centrality.begin(), get(edge_index, g)), get(vertex_index, g)); } } // end namespace boost #endif // BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP
bc_clustering.hpp
网页地址
文件地址
上一页
8/95
下一页
下载
( 5 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.